85676bff23cffa81b08448d5e6f6eee9b380a0c0
[occt.git] / src / Graphic3d / Graphic3d_Group_8.cxx
1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-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
20
21 // modified:     1/07/97 ; PCT : ajout texture mapping
22 //              20/07/97 ; PCT : ajout transparence texture
23 //              08/04/98 ; FGU : Ajout emission surface
24 //              30/11/98 ; FMN : S4069. Textes always visible.
25 //              22/03/04 ; SAN : OCC4895 High-level interface for controlling polygon offsets */
26
27
28 //-Version
29
30 //-Design       Declaration des variables specifiques aux groupes
31 //              de primitives
32
33 //-Warning      Un groupe est defini dans une structure
34 //              Il s'agit de la plus petite entite editable
35
36 //-References
37
38 //-Language     C++ 2.0
39
40 //-Declarations
41
42 #define OCC1174 //SAV 08/01/03 : Added back face interior color controling
43
44
45 // for the class
46 #include <Graphic3d_Group.jxx>
47 #include <Graphic3d_Group.pxx>
48 #include <Graphic3d_TextureMap.hxx>
49
50 //-Methods, in order
51
52 void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX) {
53
54   if (IsDeleted ()) return;
55
56   Standard_Real R, G, B;
57   Standard_Real AWidth;
58   Quantity_Color AColor;
59   Aspect_TypeOfLine ALType;
60
61   CTX->Values (AColor, ALType, AWidth);
62   AColor.Values (R, G, B, Quantity_TOC_RGB);
63
64   MyCGroup.ContextLine.Color.r    = float (R);
65   MyCGroup.ContextLine.Color.g    = float (G);
66   MyCGroup.ContextLine.Color.b    = float (B);
67   MyCGroup.ContextLine.LineType   = int (ALType);
68   MyCGroup.ContextLine.Width      = float (AWidth);
69   MyCGroup.ContextLine.IsDef      = 1;
70
71   int noinsert    = 1;
72   MyGraphicDriver->LineContextGroup (MyCGroup, noinsert);
73
74   MyCGroup.ContextLine.IsSet      = 1;
75
76   Update ();
77
78 }
79
80 void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX) {
81
82   if (IsDeleted ()) return;
83
84   Standard_Real R, G, B;
85   Standard_Real AWidth;
86   //Quantity_Color AColor;
87   Quantity_Color AIntColor;
88   Quantity_Color BackIntColor;
89   Quantity_Color AEdgeColor;
90   Aspect_TypeOfLine ALType;
91   Aspect_InteriorStyle AStyle;
92
93   CTX->Values (AStyle, AIntColor, BackIntColor, AEdgeColor, ALType, AWidth);
94   AIntColor.Values (R, G, B, Quantity_TOC_RGB);
95
96   MyCGroup.ContextFillArea.Style          = int (AStyle);
97   MyCGroup.ContextFillArea.IntColor.r     = float (R);
98   MyCGroup.ContextFillArea.IntColor.g     = float (G);
99   MyCGroup.ContextFillArea.IntColor.b     = float (B);
100
101 #ifdef OCC1174
102   if ( CTX->Distinguish() )
103     BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
104 #endif
105   MyCGroup.ContextFillArea.BackIntColor.r = float( R );
106   MyCGroup.ContextFillArea.BackIntColor.g = float( G );
107   MyCGroup.ContextFillArea.BackIntColor.b = float( B );
108
109   MyCGroup.ContextFillArea.Edge   = (CTX->Edge () ? 1 : 0);
110   AEdgeColor.Values (R, G, B, Quantity_TOC_RGB);
111   MyCGroup.ContextFillArea.EdgeColor.r    = float (R);
112   MyCGroup.ContextFillArea.EdgeColor.g    = float (G);
113   MyCGroup.ContextFillArea.EdgeColor.b    = float (B);
114   MyCGroup.ContextFillArea.LineType       = int (ALType);
115   MyCGroup.ContextFillArea.Width  = float (AWidth);
116   MyCGroup.ContextFillArea.Hatch  = int (CTX->HatchStyle ());
117
118   /*** Front and Back face ***/
119   MyCGroup.ContextFillArea.Distinguish    =
120     ( CTX->Distinguish () ? 1 : 0 );
121   MyCGroup.ContextFillArea.BackFace       =
122     ( CTX->BackFace () ? 1 : 0 );
123
124   /*** Back Material ***/
125   // Light specificity
126   MyCGroup.ContextFillArea.Back.Shininess =
127     float ((CTX->BackMaterial ()).Shininess ());
128   MyCGroup.ContextFillArea.Back.Ambient   =
129     float ((CTX->BackMaterial ()).Ambient ());
130   MyCGroup.ContextFillArea.Back.Diffuse   =
131     float ((CTX->BackMaterial ()).Diffuse ());
132   MyCGroup.ContextFillArea.Back.Specular  =
133     float ((CTX->BackMaterial ()).Specular ());
134   MyCGroup.ContextFillArea.Back.Transparency      =
135     float ((CTX->BackMaterial ()).Transparency ());
136   MyCGroup.ContextFillArea.Back.Emission  =
137     float ((CTX->BackMaterial ()).Emissive ());
138
139   // Reflection mode
140   MyCGroup.ContextFillArea.Back.IsAmbient =
141     ( (CTX->BackMaterial ()).ReflectionMode
142     (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
143   MyCGroup.ContextFillArea.Back.IsDiffuse =
144     ( (CTX->BackMaterial ()).ReflectionMode
145     (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
146   MyCGroup.ContextFillArea.Back.IsSpecular        =
147     ( (CTX->BackMaterial ()).ReflectionMode
148     (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
149   MyCGroup.ContextFillArea.Back.IsEmission        =
150     ( (CTX->BackMaterial ()).ReflectionMode
151     (Graphic3d_TOR_EMISSION) ? 1 : 0 );
152
153   // Material type
154   //JR/Hp
155   const Graphic3d_MaterialAspect ama = CTX->BackMaterial () ;
156   Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
157   MyCGroup.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
158
159   // Specular color
160   MyCGroup.ContextFillArea.Back.ColorSpec.r       =
161     float (((CTX->BackMaterial ()).SpecularColor ()).Red ());
162   MyCGroup.ContextFillArea.Back.ColorSpec.g       =
163     float (((CTX->BackMaterial ()).SpecularColor ()).Green ());
164   MyCGroup.ContextFillArea.Back.ColorSpec.b       =
165     float (((CTX->BackMaterial ()).SpecularColor ()).Blue ());
166
167
168   // Ambient color
169   MyCGroup.ContextFillArea.Back.ColorAmb.r        =
170     float (((CTX->BackMaterial ()).AmbientColor ()).Red ());
171   MyCGroup.ContextFillArea.Back.ColorAmb.g        =
172     float (((CTX->BackMaterial ()).AmbientColor ()).Green ());
173   MyCGroup.ContextFillArea.Back.ColorAmb.b        =
174     float (((CTX->BackMaterial ()).AmbientColor ()).Blue ());
175
176   // Diffuse color
177   MyCGroup.ContextFillArea.Back.ColorDif.r        =
178     float (((CTX->BackMaterial ()).DiffuseColor ()).Red ());
179   MyCGroup.ContextFillArea.Back.ColorDif.g        =
180     float (((CTX->BackMaterial ()).DiffuseColor ()).Green ());
181   MyCGroup.ContextFillArea.Back.ColorDif.b        =
182     float (((CTX->BackMaterial ()).DiffuseColor ()).Blue ());
183
184   // Emissive color
185   MyCGroup.ContextFillArea.Back.ColorEms.r        =
186     float (((CTX->BackMaterial ()).EmissiveColor ()).Red ());
187   MyCGroup.ContextFillArea.Back.ColorEms.g        =
188     float (((CTX->BackMaterial ()).EmissiveColor ()).Green ());
189   MyCGroup.ContextFillArea.Back.ColorEms.b        =
190     float (((CTX->BackMaterial ()).EmissiveColor ()).Blue ());
191
192   MyCGroup.ContextFillArea.Back.EnvReflexion =
193     float ((CTX->BackMaterial ()).EnvReflexion());
194
195   /*** Front Material ***/
196   // Light specificity
197   MyCGroup.ContextFillArea.Front.Shininess        =
198     float ((CTX->FrontMaterial ()).Shininess ());
199   MyCGroup.ContextFillArea.Front.Ambient  =
200     float ((CTX->FrontMaterial ()).Ambient ());
201   MyCGroup.ContextFillArea.Front.Diffuse  =
202     float ((CTX->FrontMaterial ()).Diffuse ());
203   MyCGroup.ContextFillArea.Front.Specular =
204     float ((CTX->FrontMaterial ()).Specular ());
205   MyCGroup.ContextFillArea.Front.Transparency     =
206     float ((CTX->FrontMaterial ()).Transparency ());
207   MyCGroup.ContextFillArea.Front.Emission =
208     float ((CTX->FrontMaterial ()).Emissive ());
209
210   // Reflection mode
211   MyCGroup.ContextFillArea.Front.IsAmbient        =
212     ( (CTX->FrontMaterial ()).ReflectionMode
213     (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
214   MyCGroup.ContextFillArea.Front.IsDiffuse        =
215     ( (CTX->FrontMaterial ()).ReflectionMode
216     (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
217   MyCGroup.ContextFillArea.Front.IsSpecular       =
218     ( (CTX->FrontMaterial ()).ReflectionMode
219     (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
220   MyCGroup.ContextFillArea.Front.IsEmission       =
221     ( (CTX->FrontMaterial ()).ReflectionMode
222     (Graphic3d_TOR_EMISSION) ? 1 : 0 );
223
224   // Material type
225   //JR/Hp
226   const Graphic3d_MaterialAspect amas = CTX->FrontMaterial () ;
227   Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
228   MyCGroup.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
229
230   // Specular color
231   MyCGroup.ContextFillArea.Front.ColorSpec.r      =
232     float (((CTX->FrontMaterial ()).SpecularColor ()).Red ());
233   MyCGroup.ContextFillArea.Front.ColorSpec.g      =
234     float (((CTX->FrontMaterial ()).SpecularColor ()).Green ());
235   MyCGroup.ContextFillArea.Front.ColorSpec.b      =
236     float (((CTX->FrontMaterial ()).SpecularColor ()).Blue ());
237
238   // Ambient color
239   MyCGroup.ContextFillArea.Front.ColorAmb.r       =
240     float (((CTX->FrontMaterial ()).AmbientColor ()).Red ());
241   MyCGroup.ContextFillArea.Front.ColorAmb.g       =
242     float (((CTX->FrontMaterial ()).AmbientColor ()).Green ());
243   MyCGroup.ContextFillArea.Front.ColorAmb.b       =
244     float (((CTX->FrontMaterial ()).AmbientColor ()).Blue ());
245
246   // Diffuse color
247   MyCGroup.ContextFillArea.Front.ColorDif.r       =
248     float (((CTX->FrontMaterial ()).DiffuseColor ()).Red ());
249   MyCGroup.ContextFillArea.Front.ColorDif.g       =
250     float (((CTX->FrontMaterial ()).DiffuseColor ()).Green ());
251   MyCGroup.ContextFillArea.Front.ColorDif.b       =
252     float (((CTX->FrontMaterial ()).DiffuseColor ()).Blue ());
253
254   // Emissive color
255   MyCGroup.ContextFillArea.Front.ColorEms.r       =
256     float (((CTX->FrontMaterial ()).EmissiveColor ()).Red ());
257   MyCGroup.ContextFillArea.Front.ColorEms.g       =
258     float (((CTX->FrontMaterial ()).EmissiveColor ()).Green ());
259   MyCGroup.ContextFillArea.Front.ColorEms.b       =
260     float (((CTX->FrontMaterial ()).EmissiveColor ()).Blue ());
261
262   MyCGroup.ContextFillArea.Front.EnvReflexion =
263     float ((CTX->FrontMaterial ()).EnvReflexion());
264
265   MyCGroup.ContextFillArea.IsDef  = 1; // Definition material ok
266
267   /*** Texture map ***/
268   MyCGroup.ContextFillArea.Texture.TextureMap   = CTX->TextureMap();
269   MyCGroup.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0;
270
271   // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
272   Standard_Integer aPolyMode;
273   Standard_ShortReal    aPolyFactor, aPolyUnits;
274   CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
275   MyCGroup.ContextFillArea.PolygonOffsetMode   = aPolyMode;
276   MyCGroup.ContextFillArea.PolygonOffsetFactor = aPolyFactor;
277   MyCGroup.ContextFillArea.PolygonOffsetUnits  = aPolyUnits;
278   // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
279
280   int noinsert = 1;
281   MyGraphicDriver->FaceContextGroup (MyCGroup, noinsert);
282
283   MyCGroup.ContextFillArea.IsSet  = 1;
284
285   Update ();
286
287 }
288
289 void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX) {
290
291   if (IsDeleted ()) return;
292
293   Standard_Real R, G, B;
294   Standard_Real AScale;
295   Quantity_Color AColor;
296   Aspect_TypeOfMarker AMType;
297
298   CTX->Values (AColor, AMType, AScale);
299   AColor.Values (R, G, B, Quantity_TOC_RGB);
300
301   MyCGroup.ContextMarker.Color.r  = float (R);
302   MyCGroup.ContextMarker.Color.g  = float (G);
303   MyCGroup.ContextMarker.Color.b  = float (B);
304   MyCGroup.ContextMarker.MarkerType       = int (AMType);
305   MyCGroup.ContextMarker.Scale    = float (AScale);
306   MyCGroup.ContextMarker.IsDef    = 1;
307
308   int noinsert    = 1;
309   if ( AMType == Aspect_TOM_USERDEFINED )
310   {
311     CTX->GetTextureSize( MyMarkWidth, MyMarkHeight );
312     MyMarkArray = CTX->GetTexture();
313     MyGraphicDriver->MarkerContextGroup (MyCGroup, noinsert, MyMarkWidth, MyMarkHeight, MyMarkArray);
314   }
315   else
316     MyGraphicDriver->MarkerContextGroup (MyCGroup, noinsert);
317
318   MyCGroup.ContextMarker.IsSet    = 1;
319
320   Update ();
321
322 }
323
324 void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX) {
325
326   if (IsDeleted ()) return;
327
328   Standard_CString AFont;
329   Standard_Real R, G, B;
330   Standard_Real Rs, Gs, Bs;
331   Standard_Real ASpace;
332   Standard_Real AnExpansion;
333   Quantity_Color AColor;
334   Aspect_TypeOfStyleText  AStyle;
335   Aspect_TypeOfDisplayText ADisplayType;
336   Quantity_Color AColorSubTitle;
337   Standard_Boolean ATextZoomable;
338   Standard_Real    ATextAngle;
339   Font_FontAspect   ATextFontAspect;
340
341   CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect);
342   AColor.Values (R, G, B, Quantity_TOC_RGB);
343   AColorSubTitle.Values (Rs, Gs, Bs, Quantity_TOC_RGB);
344
345   MyCGroup.ContextText.Color.r    = float (R);
346   MyCGroup.ContextText.Color.g    = float (G);
347   MyCGroup.ContextText.Color.b    = float (B);
348   MyCGroup.ContextText.Font       = (char*)AFont;
349   MyCGroup.ContextText.Expan      = float (AnExpansion);
350   MyCGroup.ContextText.Space      = float (ASpace);
351   MyCGroup.ContextText.Style      = int (AStyle);
352   MyCGroup.ContextText.DisplayType= int (ADisplayType);
353   MyCGroup.ContextText.ColorSubTitle.r    = float (Rs);
354   MyCGroup.ContextText.ColorSubTitle.g    = float (Gs);
355   MyCGroup.ContextText.ColorSubTitle.b    = float (Bs);
356   MyCGroup.ContextText.TextZoomable   = ATextZoomable;
357   MyCGroup.ContextText.TextAngle    = float (ATextAngle);
358   MyCGroup.ContextText.TextFontAspect   = (int)ATextFontAspect;
359
360   MyCGroup.ContextText.IsDef      = 1;
361
362   int noinsert    = 1;
363   MyGraphicDriver->TextContextGroup (MyCGroup, noinsert);
364
365   MyCGroup.ContextText.IsSet              = 1;
366
367   Update ();
368
369 }
370
371 void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX) {
372
373   if (IsDeleted ()) return;
374
375   Standard_Real R, G, B;
376   Standard_Real AWidth;
377   Quantity_Color AColor;
378   Aspect_TypeOfLine ALType;
379
380   CTX->Values (AColor, ALType, AWidth);
381   AColor.Values (R, G, B, Quantity_TOC_RGB);
382
383   MyCGroup.ContextLine.Color.r    = float (R);
384   MyCGroup.ContextLine.Color.g    = float (G);
385   MyCGroup.ContextLine.Color.b    = float (B);
386   MyCGroup.ContextLine.LineType   = int (ALType);
387   MyCGroup.ContextLine.Width              = float (AWidth);
388   MyCGroup.ContextLine.IsDef              = 1;
389
390   int noinsert    = 0;
391   MyGraphicDriver->LineContextGroup (MyCGroup, noinsert);
392
393   MyCGroup.ContextLine.IsSet              = 1;
394
395   Update ();
396
397 }
398
399 void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX) {
400
401   if (IsDeleted ()) return;
402
403   Standard_Real R, G, B;
404   Standard_Real AWidth;
405   Quantity_Color AIntColor;
406   Quantity_Color BackIntColor;
407   Quantity_Color AEdgeColor;
408   Aspect_TypeOfLine ALType;
409   Aspect_InteriorStyle AStyle;
410
411   CTX->Values (AStyle, AIntColor, BackIntColor, AEdgeColor, ALType, AWidth);
412   AIntColor.Values (R, G, B, Quantity_TOC_RGB);
413
414   MyCGroup.ContextFillArea.Style          = int (AStyle);
415   MyCGroup.ContextFillArea.IntColor.r     = float (R);
416   MyCGroup.ContextFillArea.IntColor.g     = float (G);
417   MyCGroup.ContextFillArea.IntColor.b     = float (B);
418 #ifdef OCC1174
419   if ( CTX->Distinguish() )
420     BackIntColor.Values( R, G, B, Quantity_TOC_RGB );
421 #endif
422   MyCGroup.ContextFillArea.BackIntColor.r = float( R );
423   MyCGroup.ContextFillArea.BackIntColor.g = float( G );
424   MyCGroup.ContextFillArea.BackIntColor.b = float( B );
425
426   MyCGroup.ContextFillArea.Edge   = (CTX->Edge () ? 1 : 0);
427   AEdgeColor.Values (R, G, B, Quantity_TOC_RGB);
428   MyCGroup.ContextFillArea.EdgeColor.r    = float (R);
429   MyCGroup.ContextFillArea.EdgeColor.g    = float (G);
430   MyCGroup.ContextFillArea.EdgeColor.b    = float (B);
431   MyCGroup.ContextFillArea.LineType       = int (ALType);
432   MyCGroup.ContextFillArea.Width  = float (AWidth);
433   MyCGroup.ContextFillArea.Hatch  = int (CTX->HatchStyle ());
434   // Front and Back face
435   MyCGroup.ContextFillArea.Distinguish    =
436     ( CTX->Distinguish () ? 1 : 0 );
437   MyCGroup.ContextFillArea.BackFace       =
438     ( CTX->BackFace () ? 1 : 0 );
439
440   /*** Back Material ***/
441   // Material state
442   MyCGroup.ContextFillArea.Back.Shininess =
443     float ((CTX->BackMaterial ()).Shininess ());
444   MyCGroup.ContextFillArea.Back.Ambient   =
445     float ((CTX->BackMaterial ()).Ambient ());
446   MyCGroup.ContextFillArea.Back.Diffuse   =
447     float ((CTX->BackMaterial ()).Diffuse ());
448   MyCGroup.ContextFillArea.Back.Specular  =
449     float ((CTX->BackMaterial ()).Specular ());
450   MyCGroup.ContextFillArea.Back.Transparency      =
451     float ((CTX->BackMaterial ()).Transparency ());
452   MyCGroup.ContextFillArea.Back.Emission  =
453     float ((CTX->BackMaterial ()).Emissive ());
454
455   // Reflection mode
456   MyCGroup.ContextFillArea.Back.IsAmbient =
457     ( (CTX->BackMaterial ()).ReflectionMode
458     (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
459   MyCGroup.ContextFillArea.Back.IsDiffuse =
460     ( (CTX->BackMaterial ()).ReflectionMode
461     (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
462   MyCGroup.ContextFillArea.Back.IsSpecular        =
463     ( (CTX->BackMaterial ()).ReflectionMode
464     (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
465   MyCGroup.ContextFillArea.Back.IsEmission        =
466     ( (CTX->BackMaterial ()).ReflectionMode
467     (Graphic3d_TOR_EMISSION) ? 1 : 0 );
468
469   // Material type
470   //JR/Hp
471   const Graphic3d_MaterialAspect ama = CTX->BackMaterial () ;
472   Standard_Boolean amt = ama.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
473   MyCGroup.ContextFillArea.Back.IsPhysic = ( amt ? 1 : 0 );
474
475   // Specular color
476   MyCGroup.ContextFillArea.Back.ColorSpec.r       =
477     float (((CTX->BackMaterial ()).SpecularColor ()).Red ());
478   MyCGroup.ContextFillArea.Back.ColorSpec.g       =
479     float (((CTX->BackMaterial ()).SpecularColor ()).Green ());
480   MyCGroup.ContextFillArea.Back.ColorSpec.b       =
481     float (((CTX->BackMaterial ()).SpecularColor ()).Blue ());
482
483   // Ambient color
484   MyCGroup.ContextFillArea.Back.ColorAmb.r        =
485     float (((CTX->BackMaterial ()).AmbientColor ()).Red ());
486   MyCGroup.ContextFillArea.Back.ColorAmb.g        =
487     float (((CTX->BackMaterial ()).AmbientColor ()).Green ());
488   MyCGroup.ContextFillArea.Back.ColorAmb.b        =
489     float (((CTX->BackMaterial ()).AmbientColor ()).Blue ());
490
491   // Diffuse color
492   MyCGroup.ContextFillArea.Back.ColorDif.r        =
493     float (((CTX->BackMaterial ()).DiffuseColor ()).Red ());
494   MyCGroup.ContextFillArea.Back.ColorDif.g        =
495     float (((CTX->BackMaterial ()).DiffuseColor ()).Green ());
496   MyCGroup.ContextFillArea.Back.ColorDif.b        =
497     float (((CTX->BackMaterial ()).DiffuseColor ()).Blue ());
498
499   // Emissive color
500   MyCGroup.ContextFillArea.Back.ColorEms.r        =
501     float (((CTX->BackMaterial ()).EmissiveColor ()).Red ());
502   MyCGroup.ContextFillArea.Back.ColorEms.g        =
503     float (((CTX->BackMaterial ()).EmissiveColor ()).Green ());
504   MyCGroup.ContextFillArea.Back.ColorEms.b        =
505     float (((CTX->BackMaterial ()).EmissiveColor ()).Blue ());
506
507   MyCGroup.ContextFillArea.Back.EnvReflexion =
508     float ((CTX->BackMaterial ()).EnvReflexion());
509
510   /*** Front Material ***/
511   // Ligth specificity
512   MyCGroup.ContextFillArea.Front.Shininess        =
513     float ((CTX->FrontMaterial ()).Shininess ());
514   MyCGroup.ContextFillArea.Front.Ambient  =
515     float ((CTX->FrontMaterial ()).Ambient ());
516   MyCGroup.ContextFillArea.Front.Diffuse  =
517     float ((CTX->FrontMaterial ()).Diffuse ());
518   MyCGroup.ContextFillArea.Front.Specular =
519     float ((CTX->FrontMaterial ()).Specular ());
520   MyCGroup.ContextFillArea.Front.Transparency     =
521     float ((CTX->FrontMaterial ()).Transparency ());
522   MyCGroup.ContextFillArea.Front.Emission =
523     float ((CTX->FrontMaterial ()).Emissive ());
524
525   // Reflection mode
526   MyCGroup.ContextFillArea.Front.IsAmbient        =
527     ( (CTX->FrontMaterial ()).ReflectionMode
528     (Graphic3d_TOR_AMBIENT) ? 1 : 0 );
529   MyCGroup.ContextFillArea.Front.IsDiffuse        =
530     ( (CTX->FrontMaterial ()).ReflectionMode
531     (Graphic3d_TOR_DIFFUSE) ? 1 : 0 );
532   MyCGroup.ContextFillArea.Front.IsSpecular       =
533     ( (CTX->FrontMaterial ()).ReflectionMode
534     (Graphic3d_TOR_SPECULAR) ? 1 : 0 );
535   MyCGroup.ContextFillArea.Front.IsEmission       =
536     ( (CTX->FrontMaterial ()).ReflectionMode
537     (Graphic3d_TOR_EMISSION) ? 1 : 0 );
538
539   //Material type
540   //JR/Hp
541   const Graphic3d_MaterialAspect amas = CTX->FrontMaterial () ;
542   Standard_Boolean amty = amas.MaterialType(Graphic3d_MATERIAL_PHYSIC) ;
543   MyCGroup.ContextFillArea.Front.IsPhysic = ( amty ? 1 : 0 );
544
545   // Specular color
546   MyCGroup.ContextFillArea.Front.ColorSpec.r      =
547     float (((CTX->FrontMaterial ()).SpecularColor ()).Red ());
548   MyCGroup.ContextFillArea.Front.ColorSpec.g      =
549     float (((CTX->FrontMaterial ()).SpecularColor ()).Green ());
550   MyCGroup.ContextFillArea.Front.ColorSpec.b      =
551     float (((CTX->FrontMaterial ()).SpecularColor ()).Blue ());
552
553   // Ambient color
554   MyCGroup.ContextFillArea.Front.ColorAmb.r       =
555     float (((CTX->FrontMaterial ()).AmbientColor ()).Red ());
556   MyCGroup.ContextFillArea.Front.ColorAmb.g       =
557     float (((CTX->FrontMaterial ()).AmbientColor ()).Green ());
558   MyCGroup.ContextFillArea.Front.ColorAmb.b       =
559     float (((CTX->FrontMaterial ()).AmbientColor ()).Blue ());
560
561   // Diffuse color
562   MyCGroup.ContextFillArea.Front.ColorDif.r       =
563     float (((CTX->FrontMaterial ()).DiffuseColor ()).Red ());
564   MyCGroup.ContextFillArea.Front.ColorDif.g       =
565     float (((CTX->FrontMaterial ()).DiffuseColor ()).Green ());
566   MyCGroup.ContextFillArea.Front.ColorDif.b       =
567     float (((CTX->FrontMaterial ()).DiffuseColor ()).Blue ());
568
569   // Emissive color
570   MyCGroup.ContextFillArea.Front.ColorEms.r       =
571     float (((CTX->FrontMaterial ()).EmissiveColor ()).Red ());
572   MyCGroup.ContextFillArea.Front.ColorEms.g       =
573     float (((CTX->FrontMaterial ()).EmissiveColor ()).Green ());
574   MyCGroup.ContextFillArea.Front.ColorEms.b       =
575     float (((CTX->FrontMaterial ()).EmissiveColor ()).Blue ());
576
577   MyCGroup.ContextFillArea.Front.EnvReflexion =
578     float ((CTX->FrontMaterial ()).EnvReflexion());
579
580   MyCGroup.ContextFillArea.IsDef  = 1; // Material definition ok
581
582   MyCGroup.ContextFillArea.Texture.TextureMap   = CTX->TextureMap();
583   MyCGroup.ContextFillArea.Texture.doTextureMap = CTX->TextureMapState() ? 1 : 0;
584
585   // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
586   Standard_Integer aPolyMode;
587   Standard_ShortReal    aPolyFactor, aPolyUnits;
588   CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits);
589   MyCGroup.ContextFillArea.PolygonOffsetMode   = aPolyMode;
590   MyCGroup.ContextFillArea.PolygonOffsetFactor = (Standard_ShortReal)aPolyFactor;
591   MyCGroup.ContextFillArea.PolygonOffsetUnits  = (Standard_ShortReal)aPolyUnits;
592   // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
593
594   int noinsert    = 0;
595   MyGraphicDriver->FaceContextGroup (MyCGroup, noinsert);
596
597   MyCGroup.ContextFillArea.IsSet  = 1;
598
599   Update ();
600
601 }
602
603 void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX) {
604
605   if (IsDeleted ()) return;
606
607   Standard_Real R, G, B;
608   Standard_Real AScale;
609   Quantity_Color AColor;
610   Aspect_TypeOfMarker AMType;
611
612   CTX->Values (AColor, AMType, AScale);
613   AColor.Values (R, G, B, Quantity_TOC_RGB);
614
615   MyCGroup.ContextMarker.Color.r  = float (R);
616   MyCGroup.ContextMarker.Color.g  = float (G);
617   MyCGroup.ContextMarker.Color.b  = float (B);
618   MyCGroup.ContextMarker.MarkerType       = int (AMType);
619   MyCGroup.ContextMarker.Scale    = float (AScale);
620   MyCGroup.ContextMarker.IsDef    = 1;
621
622   int noinsert    = 0;
623   if ( AMType == Aspect_TOM_USERDEFINED )
624   {
625     CTX->GetTextureSize( MyMarkWidth, MyMarkHeight );
626     MyMarkArray = CTX->GetTexture();
627     MyGraphicDriver->MarkerContextGroup (MyCGroup, noinsert, MyMarkWidth, MyMarkHeight, MyMarkArray);
628   }
629   else
630     MyGraphicDriver->MarkerContextGroup (MyCGroup, noinsert);
631
632   MyCGroup.ContextMarker.IsSet    = 1;
633
634   Update ();
635
636 }
637
638 void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX) {
639
640   if (IsDeleted ()) return;
641
642   Standard_CString AFont;
643   Standard_Real R, G, B;
644   Standard_Real Rs, Gs, Bs;
645   Standard_Real ASpace;
646   Standard_Real AnExpansion;
647   Quantity_Color AColor;
648   Aspect_TypeOfStyleText  AStyle;
649   Aspect_TypeOfDisplayText ADisplayType;
650   Quantity_Color AColorSubTitle;
651   Standard_Boolean ATextZoomable;
652   Standard_Real ATextAngle;
653   Font_FontAspect ATextFontAspect;
654
655   CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect);
656   AColor.Values (R, G, B, Quantity_TOC_RGB);
657   AColorSubTitle.Values (Rs, Gs, Bs, Quantity_TOC_RGB);
658
659   MyCGroup.ContextText.Color.r    = float (R);
660   MyCGroup.ContextText.Color.g    = float (G);
661   MyCGroup.ContextText.Color.b    = float (B);
662   MyCGroup.ContextText.Font       = (char*)AFont;
663   MyCGroup.ContextText.Expan      = float (AnExpansion);
664   MyCGroup.ContextText.Space      = float (ASpace);
665   MyCGroup.ContextText.Style      = int (AStyle);
666   MyCGroup.ContextText.DisplayType= int (ADisplayType);
667   MyCGroup.ContextText.ColorSubTitle.r    = float (Rs);
668   MyCGroup.ContextText.ColorSubTitle.g    = float (Gs);
669   MyCGroup.ContextText.ColorSubTitle.b    = float (Bs);
670   MyCGroup.ContextText.TextZoomable   = ATextZoomable;
671   MyCGroup.ContextText.TextAngle    = float (ATextAngle);
672   MyCGroup.ContextText.TextFontAspect   = (int)ATextFontAspect;
673   MyCGroup.ContextText.IsDef              = 1;
674
675   int noinsert    = 0;
676   MyGraphicDriver->TextContextGroup (MyCGroup, noinsert);
677
678   MyCGroup.ContextText.IsSet              = 1;
679
680   Update ();
681
682 }
683
684 Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const {
685     switch (theAspect) {
686         case Graphic3d_ASPECT_LINE:      return MyCGroup.ContextLine.IsSet;
687         case Graphic3d_ASPECT_TEXT:      return MyCGroup.ContextText.IsSet;
688         case Graphic3d_ASPECT_MARKER:    return MyCGroup.ContextMarker.IsSet;
689         case Graphic3d_ASPECT_FILL_AREA: return MyCGroup.ContextFillArea.IsSet;
690         default: return Standard_False;
691     }
692 }
693
694
695 void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const {
696
697   Standard_Real           R, G, B;
698   Standard_Real           Rs, Gs, Bs;
699   Quantity_Color          AColor;
700
701   Standard_Real           AWidth;
702   Aspect_TypeOfLine       ALType;
703
704   Standard_CString    AFont;
705   Standard_Real           ASpace;
706   Standard_Real           AnExpansion;
707
708   Standard_Real           AScale;
709   Aspect_TypeOfMarker     AMType;
710
711   Quantity_Color          AnIntColor;
712   Quantity_Color          AnEdgeColor;
713   Aspect_InteriorStyle    AStyle;
714   Standard_Boolean        EdgeOn = Standard_False;
715   Graphic3d_MaterialAspect Front;
716   Graphic3d_MaterialAspect Back;
717   Aspect_TypeOfStyleText   AStyleT;
718   Aspect_TypeOfDisplayText ADisplayType;
719   Quantity_Color          AColorSubTitle;
720
721   if (MyCGroup.ContextLine.IsSet) {
722     R   = Standard_Real (MyCGroup.ContextLine.Color.r);
723     G   = Standard_Real (MyCGroup.ContextLine.Color.g);
724     B   = Standard_Real (MyCGroup.ContextLine.Color.b);
725     ALType      = Aspect_TypeOfLine (MyCGroup.ContextLine.LineType);
726     AWidth      = Standard_Real (MyCGroup.ContextLine.Width);
727   }
728   else {
729     R   = Standard_Real (MyCGroup.Struct->ContextLine.Color.r);
730     G   = Standard_Real (MyCGroup.Struct->ContextLine.Color.g);
731     B   = Standard_Real (MyCGroup.Struct->ContextLine.Color.b);
732     ALType      = Aspect_TypeOfLine (MyCGroup.Struct->ContextLine.LineType);
733     AWidth      = Standard_Real (MyCGroup.Struct->ContextLine.Width);
734   }
735   AColor.SetValues (R, G, B, Quantity_TOC_RGB);
736   CTXL->SetColor (AColor);
737   CTXL->SetType (ALType);
738   CTXL->SetWidth (AWidth);
739
740   if (MyCGroup.ContextText.IsSet) {
741     R   = Standard_Real (MyCGroup.ContextText.Color.r);
742     G   = Standard_Real (MyCGroup.ContextText.Color.g);
743     B   = Standard_Real (MyCGroup.ContextText.Color.b);
744     Rs  = Standard_Real (MyCGroup.ContextText.ColorSubTitle.r);
745     Gs  = Standard_Real (MyCGroup.ContextText.ColorSubTitle.g);
746     Bs  = Standard_Real (MyCGroup.ContextText.ColorSubTitle.b);
747     AFont       = Standard_CString (MyCGroup.ContextText.Font);
748     AnExpansion = Standard_Real (MyCGroup.ContextText.Expan);
749     ASpace      = Standard_Real (MyCGroup.ContextText.Space);
750     AStyleT     = Aspect_TypeOfStyleText (MyCGroup.ContextText.Style);
751     ADisplayType= Aspect_TypeOfDisplayText (MyCGroup.ContextText.DisplayType);
752   }
753   else {
754     R   = Standard_Real (MyCGroup.Struct->ContextText.Color.r);
755     G   = Standard_Real (MyCGroup.Struct->ContextText.Color.g);
756     B   = Standard_Real (MyCGroup.Struct->ContextText.Color.b);
757     Rs  = Standard_Real (MyCGroup.Struct->ContextText.ColorSubTitle.r);
758     Gs  = Standard_Real (MyCGroup.Struct->ContextText.ColorSubTitle.g);
759     Bs  = Standard_Real (MyCGroup.Struct->ContextText.ColorSubTitle.b);
760     AFont       = Standard_CString (MyCGroup.Struct->ContextText.Font);
761     AnExpansion = Standard_Real (MyCGroup.Struct->ContextText.Expan);
762     ASpace      = Standard_Real (MyCGroup.Struct->ContextText.Space);
763     AStyleT     = Aspect_TypeOfStyleText (MyCGroup.Struct->ContextText.Style);
764     ADisplayType= Aspect_TypeOfDisplayText (MyCGroup.Struct->ContextText.DisplayType);
765   }
766   AColor.SetValues (R, G, B, Quantity_TOC_RGB);
767   AColorSubTitle.SetValues (Rs, Gs, Bs, Quantity_TOC_RGB);
768   CTXT->SetColor (AColor);
769   CTXT->SetFont (AFont);
770   CTXT->SetExpansionFactor (AnExpansion);
771   CTXT->SetSpace (ASpace);
772   CTXT->SetStyle (AStyleT);
773   CTXT->SetDisplayType (ADisplayType);
774   CTXT->SetColorSubTitle (AColorSubTitle);
775
776   if (MyCGroup.ContextMarker.IsSet) {
777     R   = Standard_Real (MyCGroup.ContextMarker.Color.r);
778     G   = Standard_Real (MyCGroup.ContextMarker.Color.g);
779     B   = Standard_Real (MyCGroup.ContextMarker.Color.b);
780     AMType      = Aspect_TypeOfMarker (MyCGroup.ContextMarker.MarkerType);
781     AScale      = Standard_Real (MyCGroup.ContextMarker.Scale);
782     if( AMType == Aspect_TOM_USERDEFINED )
783     {
784
785       CTXM->SetTexture( MyMarkWidth, MyMarkHeight, MyMarkArray );
786     }
787   }
788   else {
789     R   = Standard_Real (MyCGroup.Struct->ContextMarker.Color.r);
790     G   = Standard_Real (MyCGroup.Struct->ContextMarker.Color.g);
791     B   = Standard_Real (MyCGroup.Struct->ContextMarker.Color.b);
792     AMType      = Aspect_TypeOfMarker (MyCGroup.Struct->ContextMarker.MarkerType);
793     AScale      = Standard_Real (MyCGroup.Struct->ContextMarker.Scale);
794   }
795   AColor.SetValues (R, G, B, Quantity_TOC_RGB);
796   CTXM->SetColor (AColor);
797   CTXM->SetType (AMType);
798   CTXM->SetScale (AScale);
799
800   if (MyCGroup.ContextFillArea.IsSet) {
801     // Interior
802     AStyle      = Aspect_InteriorStyle (MyCGroup.ContextFillArea.Style);
803     R   = Standard_Real (MyCGroup.ContextFillArea.IntColor.r);
804     G   = Standard_Real (MyCGroup.ContextFillArea.IntColor.g);
805     B   = Standard_Real (MyCGroup.ContextFillArea.IntColor.b);
806     AnIntColor.SetValues (R, G, B, Quantity_TOC_RGB);
807     // Edges
808     if (MyCGroup.ContextFillArea.Edge == 1) EdgeOn = Standard_True;
809     R   = Standard_Real (MyCGroup.ContextFillArea.EdgeColor.r);
810     G   = Standard_Real (MyCGroup.ContextFillArea.EdgeColor.g);
811     B   = Standard_Real (MyCGroup.ContextFillArea.EdgeColor.b);
812     AnEdgeColor.SetValues (R, G, B, Quantity_TOC_RGB);
813     ALType      = Aspect_TypeOfLine (MyCGroup.ContextFillArea.LineType);
814     AWidth      = Standard_Real (MyCGroup.ContextFillArea.Width);
815     // Back Material
816     Back.SetShininess (
817       Standard_Real (MyCGroup.ContextFillArea.Back.Shininess));
818     Back.SetAmbient (
819       Standard_Real (MyCGroup.ContextFillArea.Back.Ambient));
820     Back.SetDiffuse (
821       Standard_Real (MyCGroup.ContextFillArea.Back.Diffuse));
822     Back.SetSpecular (
823       Standard_Real (MyCGroup.ContextFillArea.Back.Specular));
824     Back.SetTransparency (
825       Standard_Real (MyCGroup.ContextFillArea.Back.Transparency));
826     Back.SetEmissive (
827       Standard_Real (MyCGroup.ContextFillArea.Back.Emission));
828     if (MyCGroup.ContextFillArea.Back.IsAmbient == 1)
829       Back.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
830     else
831       Back.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
832     if (MyCGroup.ContextFillArea.Back.IsDiffuse == 1)
833       Back.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
834     else
835       Back.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
836     if (MyCGroup.ContextFillArea.Back.IsSpecular == 1)
837       Back.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
838     else
839       Back.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
840
841     R   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorSpec.r);
842     G   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorSpec.g);
843     B   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorSpec.b);
844     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
845     Back.SetSpecularColor (AColor);
846
847     R   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorAmb.r);
848     G   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorAmb.g);
849     B   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorAmb.b);
850     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
851     Back.SetAmbientColor (AColor);
852
853     R   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorDif.r);
854     G   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorDif.g);
855     B   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorDif.b);
856     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
857     Back.SetDiffuseColor (AColor);
858
859     R   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorEms.r);
860     G   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorEms.g);
861     B   = Standard_Real (MyCGroup.ContextFillArea.Back.ColorEms.b);
862     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
863     Back.SetEmissiveColor (AColor);
864
865     Back.SetEnvReflexion (MyCGroup.ContextFillArea.Back.EnvReflexion);
866     // Front Material
867     Front.SetShininess (
868       Standard_Real (MyCGroup.ContextFillArea.Front.Shininess));
869     Front.SetAmbient (
870       Standard_Real (MyCGroup.ContextFillArea.Front.Ambient));
871     Front.SetDiffuse (
872       Standard_Real (MyCGroup.ContextFillArea.Front.Diffuse));
873     Front.SetSpecular (
874       Standard_Real (MyCGroup.ContextFillArea.Front.Specular));
875     Front.SetTransparency (
876       Standard_Real (MyCGroup.ContextFillArea.Front.Transparency));
877     Front.SetEmissive (
878       Standard_Real (MyCGroup.ContextFillArea.Back.Emission));
879     if (MyCGroup.ContextFillArea.Front.IsAmbient == 1)
880       Front.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
881     else
882       Front.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
883     if (MyCGroup.ContextFillArea.Front.IsDiffuse == 1)
884       Front.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
885     else
886       Front.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
887     if (MyCGroup.ContextFillArea.Front.IsSpecular == 1)
888       Front.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
889     else
890       Front.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
891
892     R   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorSpec.r);
893     G   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorSpec.g);
894     B   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorSpec.b);
895     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
896     Front.SetSpecularColor (AColor);
897
898     R   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorAmb.r);
899     G   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorAmb.g);
900     B   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorAmb.b);
901     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
902     Front.SetAmbientColor (AColor);
903
904     R   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorDif.r);
905     G   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorDif.g);
906     B   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorDif.b);
907     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
908     Front.SetDiffuseColor (AColor);
909
910     R   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorEms.r);
911     G   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorEms.g);
912     B   = Standard_Real (MyCGroup.ContextFillArea.Front.ColorEms.b);
913     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
914     Front.SetEmissiveColor (AColor);
915
916     Front.SetEnvReflexion (MyCGroup.ContextFillArea.Front.EnvReflexion);
917
918     // Edges
919     if (EdgeOn)
920       CTXF->SetEdgeOn ();
921     else
922       CTXF->SetEdgeOff ();
923     // Hatch
924     CTXF->SetHatchStyle(Aspect_HatchStyle (MyCGroup.ContextFillArea.Hatch));
925     // Materials
926     // Front and Back face
927     if (MyCGroup.ContextFillArea.Distinguish == 1)
928       CTXF->SetDistinguishOn ();
929     else
930       CTXF->SetDistinguishOff ();
931     if (MyCGroup.ContextFillArea.BackFace == 1)
932       CTXF->SuppressBackFace ();
933     else
934       CTXF->AllowBackFace ();
935     // Texture
936     CTXF->SetTextureMap (MyCGroup.ContextFillArea.Texture.TextureMap);
937     if (MyCGroup.ContextFillArea.Texture.doTextureMap == 1)
938     {
939       CTXF->SetTextureMapOn();
940     }
941     else
942     {
943       CTXF->SetTextureMapOff();
944     }
945
946     // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
947     CTXF->SetPolygonOffsets(MyCGroup.ContextFillArea.PolygonOffsetMode,
948       MyCGroup.ContextFillArea.PolygonOffsetFactor,
949       MyCGroup.ContextFillArea.PolygonOffsetUnits);
950     // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
951   }
952   else {
953     // Interior
954     AStyle      = Aspect_InteriorStyle (MyCGroup.Struct->ContextFillArea.Style);
955     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.IntColor.r);
956     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.IntColor.g);
957     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.IntColor.b);
958     AnIntColor.SetValues (R, G, B, Quantity_TOC_RGB);
959     // Edges
960     if (MyCGroup.Struct->ContextFillArea.Edge == 1) EdgeOn = Standard_True;
961     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.EdgeColor.r);
962     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.EdgeColor.g);
963     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.EdgeColor.b);
964     AnEdgeColor.SetValues (R, G, B, Quantity_TOC_RGB);
965     ALType      = Aspect_TypeOfLine (MyCGroup.Struct->ContextFillArea.LineType);
966     AWidth      = Standard_Real (MyCGroup.Struct->ContextFillArea.Width);
967     // Back Material
968     Back.SetShininess (
969       Standard_Real (MyCGroup.Struct->ContextFillArea.Back.Shininess));
970     Back.SetAmbient (
971       Standard_Real (MyCGroup.Struct->ContextFillArea.Back.Ambient));
972     Back.SetDiffuse (
973       Standard_Real (MyCGroup.Struct->ContextFillArea.Back.Diffuse));
974     Back.SetSpecular (
975       Standard_Real (MyCGroup.Struct->ContextFillArea.Back.Specular));
976     Back.SetTransparency (
977       Standard_Real (MyCGroup.Struct->ContextFillArea.Back.Transparency));
978     Back.SetEmissive (
979       Standard_Real (MyCGroup.Struct->ContextFillArea.Back.Emission));
980     if (MyCGroup.Struct->ContextFillArea.Back.IsAmbient == 1)
981       Back.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
982     else
983       Back.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
984     if (MyCGroup.Struct->ContextFillArea.Back.IsDiffuse == 1)
985       Back.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
986     else
987       Back.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
988     if (MyCGroup.Struct->ContextFillArea.Back.IsSpecular == 1)
989       Back.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
990     else
991       Back.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
992
993     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorSpec.r);
994     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorSpec.g);
995     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorSpec.b);
996     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
997     Back.SetSpecularColor (AColor);
998
999     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorAmb.r);
1000     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorAmb.g);
1001     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorAmb.b);
1002     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1003     Back.SetAmbientColor (AColor);
1004
1005     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorDif.r);
1006     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorDif.g);
1007     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorDif.b);
1008     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1009     Back.SetDiffuseColor (AColor);
1010
1011     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorEms.r);
1012     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorEms.g);
1013     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Back.ColorEms.b);
1014     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1015     Back.SetEmissiveColor (AColor);
1016
1017     Back.SetEnvReflexion (MyCGroup.Struct->ContextFillArea.Back.EnvReflexion);
1018     // Front Material
1019     Front.SetShininess (
1020       Standard_Real (MyCGroup.Struct->ContextFillArea.Front.Shininess));
1021     Front.SetAmbient (
1022       Standard_Real (MyCGroup.Struct->ContextFillArea.Front.Ambient));
1023     Front.SetDiffuse (
1024       Standard_Real (MyCGroup.Struct->ContextFillArea.Front.Diffuse));
1025     Front.SetSpecular (
1026       Standard_Real (MyCGroup.Struct->ContextFillArea.Front.Specular));
1027     Front.SetTransparency (
1028       Standard_Real (MyCGroup.Struct->ContextFillArea.Front.Transparency));
1029     Front.SetEmissive (
1030       Standard_Real (MyCGroup.Struct->ContextFillArea.Front.Emission));
1031     if (MyCGroup.Struct->ContextFillArea.Front.IsAmbient == 1)
1032       Front.SetReflectionModeOn (Graphic3d_TOR_AMBIENT);
1033     else
1034       Front.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
1035     if (MyCGroup.Struct->ContextFillArea.Front.IsDiffuse == 1)
1036       Front.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE);
1037     else
1038       Front.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
1039     if (MyCGroup.Struct->ContextFillArea.Front.IsSpecular == 1)
1040       Front.SetReflectionModeOn (Graphic3d_TOR_SPECULAR);
1041     else
1042       Front.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
1043
1044     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorSpec.r);
1045     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorSpec.g);
1046     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorSpec.b);
1047     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1048     Front.SetSpecularColor (AColor);
1049
1050     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorAmb.r);
1051     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorAmb.g);
1052     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorAmb.b);
1053     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1054     Front.SetAmbientColor (AColor);
1055
1056     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorDif.r);
1057     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorDif.g);
1058     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorDif.b);
1059     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1060     Front.SetDiffuseColor (AColor);
1061
1062     R   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorEms.r);
1063     G   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorEms.g);
1064     B   = Standard_Real (MyCGroup.Struct->ContextFillArea.Front.ColorEms.b);
1065     AColor.SetValues (R, G, B, Quantity_TOC_RGB);
1066     Front.SetEmissiveColor (AColor);
1067
1068     Front.SetEnvReflexion (MyCGroup.Struct->ContextFillArea.Front.EnvReflexion);
1069
1070     // Edges
1071     if (EdgeOn)
1072       CTXF->SetEdgeOn ();
1073     else
1074       CTXF->SetEdgeOff ();
1075     // Hatch
1076     CTXF->SetHatchStyle(Aspect_HatchStyle (MyCGroup.Struct->ContextFillArea.Hatch));
1077     // Materials
1078     // Front and Back face
1079     if (MyCGroup.Struct->ContextFillArea.Distinguish == 1)
1080       CTXF->SetDistinguishOn ();
1081     else
1082       CTXF->SetDistinguishOff ();
1083     if (MyCGroup.Struct->ContextFillArea.BackFace == 1)
1084       CTXF->SuppressBackFace ();
1085     else
1086       CTXF->AllowBackFace ();
1087     // Texture
1088     CTXF->SetTextureMap (MyCGroup.Struct->ContextFillArea.Texture.TextureMap);
1089     if (MyCGroup.Struct->ContextFillArea.Texture.doTextureMap == 1)
1090     {
1091       CTXF->SetTextureMapOn();
1092     }
1093     else
1094     {
1095       CTXF->SetTextureMapOff();
1096     }
1097
1098     // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
1099     CTXF->SetPolygonOffsets(MyCGroup.Struct->ContextFillArea.PolygonOffsetMode,
1100       MyCGroup.Struct->ContextFillArea.PolygonOffsetFactor,
1101       MyCGroup.Struct->ContextFillArea.PolygonOffsetUnits);
1102     // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
1103   }
1104   CTXF->SetInteriorStyle (AStyle);
1105   CTXF->SetInteriorColor (AnIntColor);
1106   CTXF->SetEdgeColor (AnEdgeColor);
1107   CTXF->SetEdgeLineType (ALType);
1108   CTXF->SetEdgeWidth (AWidth);
1109   CTXF->SetBackMaterial (Back);
1110   CTXF->SetFrontMaterial (Front);
1111 }
1112
1113 void Graphic3d_Group::PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const
1114 {
1115   GroupPrimitivesAspect (CTXL, CTXT, CTXM, CTXF);
1116 }