0024752: Visualization - inherit OpenGl_Group from Graphic3d_Group
[occt.git] / src / Graphic3d / Graphic3d_Group.cxx
CommitLineData
b311480e 1// Created by: NW,JPB,CAL
2// Copyright (c) 1991-1999 Matra Datavision
973c2be1 3// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
b64d84be 16#include <Graphic3d_Group.ixx>
7fd59977 17
b64d84be 18#include <gp_Pnt.hxx>
19#include <Graphic3d_ArrayOfPoints.hxx>
20#include <Graphic3d_StructureManager.hxx>
21#include <Graphic3d_ShaderProgram.hxx>
22#include <Graphic3d_TransModeFlags.hxx>
23#include <Graphic3d_TextureMap.hxx>
24#include <Message.hxx>
25#include <Message_Messenger.hxx>
26#include <NCollection_String.hxx>
27#include <TCollection_AsciiString.hxx>
7fd59977 28
b64d84be 29#include <Graphic3d_CStructure.hxx>
30#include <Graphic3d_Structure.pxx>
7fd59977 31
b64d84be 32#define MyIsEmpty myCBitFields.bool1
33#define MyContainsFacet myCBitFields.bool2
7fd59977 34
b64d84be 35// =======================================================================
36// function : Graphic3d_Group
37// purpose :
38// =======================================================================
39Graphic3d_Group::Graphic3d_Group (const Handle(Graphic3d_Structure)& theStruct)
40{
41 myBounds.XMin = ShortRealLast();
42 myBounds.YMin = ShortRealLast();
43 myBounds.ZMin = ShortRealLast();
44 myBounds.XMax = ShortRealFirst();
45 myBounds.YMax = ShortRealFirst();
46 myBounds.ZMax = ShortRealFirst();
7fd59977 47
b64d84be 48 //
49 // A small commentary on the usage of This!
50 //
51 // Graphic3d_Group is created in a structure. Graphic3d_Structure is a
52 // manager of Graphic3d_Group. In the constructor of Graphic3d_Group
53 // a method Add of Graphic3d_Structure is called. It allows adding
54 // the instance of Graphic3d_Group in its manager. So there are 2 references
55 // to <me> and everything works well.
56 //
57 // This () is the instance of the class, the current group
58 //Handle(Graphic3d_Group) me = Handle(Graphic3d_Group)::DownCast (This());
7fd59977 59
b64d84be 60 myStructure = theStruct.operator->();
7fd59977 61
b64d84be 62 MyContainsFacet = Standard_False,
63 MyIsEmpty = Standard_True;
7fd59977 64
b64d84be 65 ContextLine.IsDef = 0;
66 ContextText.IsDef = 0;
67 ContextMarker.IsDef = 0;
68 ContextFillArea.IsDef = 0;
7fd59977 69
b64d84be 70 ContextLine.IsSet = 0;
71 ContextText.IsSet = 0;
72 ContextMarker.IsSet = 0;
73 ContextFillArea.IsSet = 0;
74}
75
76// =======================================================================
77// function : Clear
78// purpose :
79// =======================================================================
80void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
81{
82 if (IsDeleted())
83 {
84 return;
85 }
86
87 ContextLine.IsSet = 0,
88 ContextText.IsSet = 0,
89 ContextMarker.IsSet = 0,
90 ContextFillArea.IsSet = 0;
7fd59977 91
b64d84be 92 ContextLine.IsDef = 0,
93 ContextText.IsDef = 0,
94 ContextMarker.IsDef = 0,
95 ContextFillArea.IsDef = 0;
7fd59977 96
b64d84be 97 myBounds.XMin = ShortRealLast();
98 myBounds.YMin = ShortRealLast();
99 myBounds.ZMin = ShortRealLast();
100 myBounds.XMax = ShortRealFirst();
101 myBounds.YMax = ShortRealFirst();
102 myBounds.ZMax = ShortRealFirst();
7fd59977 103
b64d84be 104 if (MyContainsFacet)
105 {
106 myStructure->GroupsWithFacet (-1);
107 MyContainsFacet = Standard_False;
108 }
109 MyIsEmpty = Standard_True;
7fd59977 110
b64d84be 111 // clear method could be used on Graphic3d_Structure destruction,
112 // and its structure manager could be already destroyed, in that
113 // case we don't need to update it;
114 if (theUpdateStructureMgr)
115 {
116 Update();
117 }
118}
7fd59977 119
b64d84be 120// =======================================================================
121// function : Destroy
122// purpose :
123// =======================================================================
124void Graphic3d_Group::Destroy()
125{
126 // tell graphics driver to clear internal resources of the group
127 Clear (Standard_False);
128}
7fd59977 129
b64d84be 130// =======================================================================
131// function : Remove
132// purpose :
133// =======================================================================
134void Graphic3d_Group::Remove()
7fd59977 135{
b64d84be 136 if (IsDeleted())
137 {
138 return;
139 }
7fd59977 140
b64d84be 141 if (MyContainsFacet)
142 {
143 myStructure->GroupsWithFacet (-1);
144 MyContainsFacet = Standard_False;
145 }
146 myStructure->Remove (this);
7fd59977 147
b64d84be 148 Update();
7fd59977 149
b64d84be 150 myBounds.XMin = ShortRealLast();
151 myBounds.YMin = ShortRealLast();
152 myBounds.ZMin = ShortRealLast();
153 myBounds.XMax = ShortRealFirst();
154 myBounds.YMax = ShortRealFirst();
155 myBounds.ZMax = ShortRealFirst();
7fd59977 156
b64d84be 157 MyIsEmpty = Standard_True;
158}
159
160// =======================================================================
161// function : IsDeleted
162// purpose :
163// =======================================================================
164Standard_Boolean Graphic3d_Group::IsDeleted() const
165{
166 return myStructure == NULL
167 || myStructure->IsDeleted();
168}
169
170// =======================================================================
171// function : ContainsFacet
172// purpose :
173// =======================================================================
174Standard_Boolean Graphic3d_Group::ContainsFacet() const
175{
176 return MyContainsFacet;
177}
178
179// =======================================================================
180// function : IsEmpty
181// purpose :
182// =======================================================================
183Standard_Boolean Graphic3d_Group::IsEmpty() const
184{
185 if (IsDeleted())
186 {
187 return Standard_True;
188 }
189
190 const Standard_ShortReal RL = ShortRealLast();
191 const Standard_ShortReal RF = ShortRealFirst();
192 const Standard_Boolean isEmpty = ((myBounds.XMin == RL) && (myBounds.YMin == RL)
193 && (myBounds.ZMin == RL) && (myBounds.XMax == RF)
194 && (myBounds.YMax == RF) && (myBounds.ZMax == RF));
195 if (isEmpty != MyIsEmpty)
196 {
197 ::Message::DefaultMessenger()->Send ("Graphic3d_Group: MyIsEmpty != IsEmpty()", Message_Trace);
198 }
199 return isEmpty;
200}
201
202// =======================================================================
203// function : SetMinMaxValues
204// purpose :
205// =======================================================================
206void Graphic3d_Group::SetMinMaxValues (const Standard_Real theXMin, const Standard_Real theYMin, const Standard_Real theZMin,
207 const Standard_Real theXMax, const Standard_Real theYMax, const Standard_Real theZMax)
208{
209 myBounds.XMin = Standard_ShortReal (theXMin);
210 myBounds.YMin = Standard_ShortReal (theYMin);
211 myBounds.ZMin = Standard_ShortReal (theZMin);
212 myBounds.XMax = Standard_ShortReal (theXMax);
213 myBounds.YMax = Standard_ShortReal (theYMax);
214 myBounds.ZMax = Standard_ShortReal (theZMax);
215}
216
217// =======================================================================
218// function : MinMaxValues
219// purpose :
220// =======================================================================
221void Graphic3d_Group::MinMaxValues (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
222 Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const
223{
224 MinMaxCoord (theXMin, theYMin, theZMin,
225 theXMax, theYMax, theZMax);
226}
227
228// =======================================================================
229// function : Structure
230// purpose :
231// =======================================================================
232Handle(Graphic3d_Structure) Graphic3d_Group::Structure() const
233{
234 return myStructure;
235}
236
237// =======================================================================
238// function : MinMaxCoord
239// purpose :
240// =======================================================================
241void Graphic3d_Group::MinMaxCoord (Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
242 Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax) const
243{
244 if (IsEmpty())
245 {
246 // Empty Group
247 theXMin = theYMin = theZMin = ShortRealFirst();
248 theXMax = theYMax = theZMax = ShortRealLast();
249 }
250 else
251 {
252 theXMin = Standard_Real (myBounds.XMin);
253 theYMin = Standard_Real (myBounds.YMin);
254 theZMin = Standard_Real (myBounds.ZMin);
255 theXMax = Standard_Real (myBounds.XMax);
256 theYMax = Standard_Real (myBounds.YMax);
257 theZMax = Standard_Real (myBounds.ZMax);
258 }
259}
260
261// =======================================================================
262// function : Update
263// purpose :
264// =======================================================================
265void Graphic3d_Group::Update() const
266{
267 if (IsDeleted())
268 {
269 return;
270 }
271
272 if (myStructure->StructureManager()->UpdateMode() == Aspect_TOU_ASAP)
273 {
274 myStructure->StructureManager()->Update();
275 }
276}
277
278// =======================================================================
279// function : SetGroupPrimitivesAspect
280// purpose :
281// =======================================================================
282void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine)
283{
284 if (IsDeleted())
285 {
286 return;
287 }
288
289 Standard_Real aWidth;
290 Quantity_Color aColor;
291 Aspect_TypeOfLine aLType;
292 theAspLine->Values (aColor, aLType, aWidth);
293
294 ContextLine.IsDef = 1;
295 ContextLine.Color.r = float (aColor.Red());
296 ContextLine.Color.g = float (aColor.Green());
297 ContextLine.Color.b = float (aColor.Blue());
298 ContextLine.LineType = aLType;
299 ContextLine.Width = float (aWidth);
300 ContextLine.ShaderProgram = theAspLine->ShaderProgram();
7fd59977 301
b64d84be 302 UpdateAspectLine (Standard_True);
7fd59977 303
b64d84be 304 ContextLine.IsSet = 1;
7fd59977 305
b64d84be 306 Update();
307}
308
309// =======================================================================
310// function : SetGroupPrimitivesAspect
311// purpose :
312// =======================================================================
313void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill)
314{
315 if (IsDeleted())
316 {
317 return;
318 }
319
320 Standard_Real anRGB[3];
321 Standard_Real aWidth;
322 Quantity_Color anIntColor;
323 Quantity_Color aBackIntColor;
324 Quantity_Color anEdgeColor;
325 Aspect_TypeOfLine aLType;
326 Aspect_InteriorStyle aStyle;
327 theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth);
328
329 anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
330 ContextFillArea.Style = aStyle;
331 ContextFillArea.IntColor.r = float (anRGB[0]);
332 ContextFillArea.IntColor.g = float (anRGB[1]);
333 ContextFillArea.IntColor.b = float (anRGB[2]);
334
335 if (theAspFill->Distinguish())
336 {
337 aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
338 }
339 ContextFillArea.BackIntColor.r = float (anRGB[0]);
340 ContextFillArea.BackIntColor.g = float (anRGB[1]);
341 ContextFillArea.BackIntColor.b = float (anRGB[2]);
342
343 // Edges
344 ContextFillArea.Edge = theAspFill->Edge() ? 1 : 0;
345 ContextFillArea.EdgeColor.r = float (anEdgeColor.Red());
346 ContextFillArea.EdgeColor.g = float (anEdgeColor.Green());
347 ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue());
348 ContextFillArea.LineType = aLType;
349 ContextFillArea.Width = float (aWidth);
350 ContextFillArea.Hatch = theAspFill->HatchStyle();
351
352 // Front and Back face
353 ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0;
354 ContextFillArea.BackFace = theAspFill->BackFace() ? 1 : 0;
355
356 // Back Material
357 const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
358
359 // Light specificity
360 ContextFillArea.Back.Shininess = float (aBack.Shininess());
361 ContextFillArea.Back.Ambient = float (aBack.Ambient());
362 ContextFillArea.Back.Diffuse = float (aBack.Diffuse());
363 ContextFillArea.Back.Specular = float (aBack.Specular());
364 ContextFillArea.Back.Transparency = float (aBack.Transparency());
365 ContextFillArea.Back.Emission = float (aBack.Emissive());
366
367 // Reflection mode
368 ContextFillArea.Back.IsAmbient = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
369 ContextFillArea.Back.IsDiffuse = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
370 ContextFillArea.Back.IsSpecular = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
371 ContextFillArea.Back.IsEmission = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
372
373 // Material type
374 ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
375
376 // Specular color
377 ContextFillArea.Back.ColorSpec.r = float (aBack.SpecularColor().Red());
378 ContextFillArea.Back.ColorSpec.g = float (aBack.SpecularColor().Green());
379 ContextFillArea.Back.ColorSpec.b = float (aBack.SpecularColor().Blue());
380
381 // Ambient color
382 ContextFillArea.Back.ColorAmb.r = float (aBack.AmbientColor().Red());
383 ContextFillArea.Back.ColorAmb.g = float (aBack.AmbientColor().Green());
384 ContextFillArea.Back.ColorAmb.b = float (aBack.AmbientColor().Blue());
385
386 // Diffuse color
387 ContextFillArea.Back.ColorDif.r = float (aBack.DiffuseColor().Red());
388 ContextFillArea.Back.ColorDif.g = float (aBack.DiffuseColor().Green());
389 ContextFillArea.Back.ColorDif.b = float (aBack.DiffuseColor().Blue());
390
391 // Emissive color
392 ContextFillArea.Back.ColorEms.r = float (aBack.EmissiveColor().Red());
393 ContextFillArea.Back.ColorEms.g = float (aBack.EmissiveColor().Green());
394 ContextFillArea.Back.ColorEms.b = float (aBack.EmissiveColor().Blue());
395
396 ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion());
397
398 // Front Material
399 const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
400 // Light specificity
401 ContextFillArea.Front.Shininess = float (aFront.Shininess());
402 ContextFillArea.Front.Ambient = float (aFront.Ambient());
403 ContextFillArea.Front.Diffuse = float (aFront.Diffuse());
404 ContextFillArea.Front.Specular = float (aFront.Specular());
405 ContextFillArea.Front.Transparency = float (aFront.Transparency());
406 ContextFillArea.Front.Emission = float (aFront.Emissive());
407
408 // Reflection mode
409 ContextFillArea.Front.IsAmbient = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
410 ContextFillArea.Front.IsDiffuse = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
411 ContextFillArea.Front.IsSpecular = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
412 ContextFillArea.Front.IsEmission = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
413
414 // Material type
415 ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
416
417 // Specular color
418 ContextFillArea.Front.ColorSpec.r = float (aFront.SpecularColor().Red());
419 ContextFillArea.Front.ColorSpec.g = float (aFront.SpecularColor().Green());
420 ContextFillArea.Front.ColorSpec.b = float (aFront.SpecularColor().Blue());
421
422 // Ambient color
423 ContextFillArea.Front.ColorAmb.r = float (aFront.AmbientColor().Red());
424 ContextFillArea.Front.ColorAmb.g = float (aFront.AmbientColor().Green());
425 ContextFillArea.Front.ColorAmb.b = float (aFront.AmbientColor().Blue());
426
427 // Diffuse color
428 ContextFillArea.Front.ColorDif.r = float (aFront.DiffuseColor().Red());
429 ContextFillArea.Front.ColorDif.g = float (aFront.DiffuseColor().Green());
430 ContextFillArea.Front.ColorDif.b = float (aFront.DiffuseColor().Blue());
431
432 // Emissive color
433 ContextFillArea.Front.ColorEms.r = float (aFront.EmissiveColor().Red());
434 ContextFillArea.Front.ColorEms.g = float (aFront.EmissiveColor().Green());
435 ContextFillArea.Front.ColorEms.b = float (aFront.EmissiveColor().Blue());
436
437 ContextFillArea.Front.EnvReflexion = float (aFront.EnvReflexion());
438
439 ContextFillArea.IsDef = 1; // Definition material ok
440
441 // Texture map
442 ContextFillArea.Texture.TextureMap = theAspFill->TextureMap();
443 ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0;
444
445 Standard_Integer aPolyMode;
446 Standard_ShortReal aPolyFactor, aPolyUnits;
447 theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits);
448 ContextFillArea.PolygonOffsetMode = aPolyMode;
449 ContextFillArea.PolygonOffsetFactor = aPolyFactor;
450 ContextFillArea.PolygonOffsetUnits = aPolyUnits;
451
452 ContextFillArea.ShaderProgram = theAspFill->ShaderProgram();
453
454 UpdateAspectFace (Standard_True);
455
456 ContextFillArea.IsSet = 1;
457
458 Update();
459}
460
461// =======================================================================
462// function : SetGroupPrimitivesAspect
463// purpose :
464// =======================================================================
465void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
466{
467 if (IsDeleted())
468 {
469 return;
470 }
471
472 Standard_Real aScale;
473 Quantity_Color aColor;
474 Aspect_TypeOfMarker aMarkerType;
475 theAspMarker->Values (aColor, aMarkerType, aScale);
476
477 ContextMarker.IsDef = 1;
478 ContextMarker.Color.r = Standard_ShortReal (aColor.Red());
479 ContextMarker.Color.g = Standard_ShortReal (aColor.Green());
480 ContextMarker.Color.b = Standard_ShortReal (aColor.Blue());
481 ContextMarker.MarkerType = aMarkerType;
482 ContextMarker.Scale = Standard_ShortReal (aScale);
483 ContextMarker.MarkerImage = theAspMarker->GetMarkerImage();
484 ContextMarker.ShaderProgram = theAspMarker->ShaderProgram();
485
486 UpdateAspectMarker (Standard_True);
487
488 ContextMarker.IsSet = 1;
489
490 Update();
491}
492
493// =======================================================================
494// function : SetGroupPrimitivesAspect
495// purpose :
496// =======================================================================
497void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
498{
499 if (IsDeleted())
500 {
501 return;
502 }
503
504 Standard_Real anExpansion, aSpace, aTextAngle;
505 Quantity_Color aColor, aColorSubTitle;
506 Standard_CString aFont;
507 Aspect_TypeOfStyleText aStyle;
508 Aspect_TypeOfDisplayText aDisplayType;
509 Standard_Boolean isTextZoomable;
510 Font_FontAspect aTextFontAspect;
511 theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType,
512 aColorSubTitle, isTextZoomable, aTextAngle, aTextFontAspect);
513
514 ContextText.IsDef = 1;
515 ContextText.Color.r = float (aColor.Red());
516 ContextText.Color.g = float (aColor.Green());
517 ContextText.Color.b = float (aColor.Blue());
518 ContextText.Font = (char* )aFont;
519 ContextText.Expan = float (anExpansion);
520 ContextText.Space = float (aSpace);
521 ContextText.Style = aStyle;
522 ContextText.DisplayType = aDisplayType;
523 ContextText.ColorSubTitle.r = float (aColorSubTitle.Red());
524 ContextText.ColorSubTitle.g = float (aColorSubTitle.Green());
525 ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue());
526 ContextText.TextZoomable = isTextZoomable;
527 ContextText.TextAngle = float (aTextAngle);
528 ContextText.TextFontAspect = aTextFontAspect;
529 ContextText.ShaderProgram = theAspText->ShaderProgram();
530
531 UpdateAspectText (Standard_True);
532
533 ContextText.IsSet = 1;
534
535 Update();
536}
537
538// =======================================================================
539// function : SetPrimitivesAspect
540// purpose :
541// =======================================================================
542void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine)
543{
544 if (IsDeleted())
545 {
546 return;
547 }
7fd59977 548
b64d84be 549 Standard_Real aWidth;
550 Quantity_Color aColor;
551 Aspect_TypeOfLine aLType;
552 theAspLine->Values (aColor, aLType, aWidth);
7fd59977 553
b64d84be 554 ContextLine.IsDef = 1;
555 ContextLine.Color.r = float (aColor.Red());
556 ContextLine.Color.g = float (aColor.Green());
557 ContextLine.Color.b = float (aColor.Blue());
558 ContextLine.LineType = aLType;
559 ContextLine.Width = float (aWidth);
560 ContextLine.ShaderProgram = theAspLine->ShaderProgram();
7fd59977 561
b64d84be 562 UpdateAspectLine (Standard_False);
7fd59977 563
b64d84be 564 ContextLine.IsSet = 1;
7fd59977 565
b64d84be 566 Update();
567}
568
569// =======================================================================
570// function : SetPrimitivesAspect
571// purpose :
572// =======================================================================
573void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspFill)
574{
575 if (IsDeleted())
576 {
577 return;
578 }
579
580 Standard_Real anRGB[3];
581 Standard_Real aWidth;
582 Quantity_Color anIntColor;
583 Quantity_Color aBackIntColor;
584 Quantity_Color anEdgeColor;
585 Aspect_TypeOfLine aLType;
586 Aspect_InteriorStyle aStyle;
587 theAspFill->Values (aStyle, anIntColor, aBackIntColor, anEdgeColor, aLType, aWidth);
588
589 anIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
590 ContextFillArea.Style = aStyle;
591 ContextFillArea.IntColor.r = float (anRGB[0]);
592 ContextFillArea.IntColor.g = float (anRGB[1]);
593 ContextFillArea.IntColor.b = float (anRGB[2]);
594
595 if (theAspFill->Distinguish())
596 {
597 aBackIntColor.Values (anRGB[0], anRGB[1], anRGB[2], Quantity_TOC_RGB);
598 }
599 ContextFillArea.BackIntColor.r = float(anRGB[0]);
600 ContextFillArea.BackIntColor.g = float(anRGB[1]);
601 ContextFillArea.BackIntColor.b = float(anRGB[2]);
602
603 // Edges
604 ContextFillArea.Edge = theAspFill->Edge() ? 1 : 0;
605 ContextFillArea.EdgeColor.r = float (anEdgeColor.Red());
606 ContextFillArea.EdgeColor.g = float (anEdgeColor.Green());
607 ContextFillArea.EdgeColor.b = float (anEdgeColor.Blue());
608 ContextFillArea.LineType = aLType;
609 ContextFillArea.Width = float (aWidth);
610 ContextFillArea.Hatch = theAspFill->HatchStyle();
611
612 // Front and Back face
613 ContextFillArea.Distinguish = theAspFill->Distinguish() ? 1 : 0;
614 ContextFillArea.BackFace = theAspFill->BackFace() ? 1 : 0;
615
616 // Back Material
617 const Graphic3d_MaterialAspect& aBack = theAspFill->BackMaterial();
618 // Material state
619 ContextFillArea.Back.Shininess = float (aBack.Shininess());
620 ContextFillArea.Back.Ambient = float (aBack.Ambient());
621 ContextFillArea.Back.Diffuse = float (aBack.Diffuse());
622 ContextFillArea.Back.Specular = float (aBack.Specular());
623 ContextFillArea.Back.Transparency = float (aBack.Transparency());
624 ContextFillArea.Back.Emission = float (aBack.Emissive());
625
626 // Reflection mode
627 ContextFillArea.Back.IsAmbient = aBack.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
628 ContextFillArea.Back.IsDiffuse = aBack.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
629 ContextFillArea.Back.IsSpecular = aBack.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
630 ContextFillArea.Back.IsEmission = aBack.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
631
632 // Material type
633 ContextFillArea.Back.IsPhysic = aBack.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
634
635 // Specular color
636 ContextFillArea.Back.ColorSpec.r = float (aBack.SpecularColor().Red());
637 ContextFillArea.Back.ColorSpec.g = float (aBack.SpecularColor().Green());
638 ContextFillArea.Back.ColorSpec.b = float (aBack.SpecularColor().Blue());
639
640 // Ambient color
641 ContextFillArea.Back.ColorAmb.r = float (aBack.AmbientColor().Red());
642 ContextFillArea.Back.ColorAmb.g = float (aBack.AmbientColor().Green());
643 ContextFillArea.Back.ColorAmb.b = float (aBack.AmbientColor().Blue());
644
645 // Diffuse color
646 ContextFillArea.Back.ColorDif.r = float (aBack.DiffuseColor().Red());
647 ContextFillArea.Back.ColorDif.g = float (aBack.DiffuseColor().Green());
648 ContextFillArea.Back.ColorDif.b = float (aBack.DiffuseColor().Blue());
649
650 // Emissive color
651 ContextFillArea.Back.ColorEms.r = float (aBack.EmissiveColor().Red());
652 ContextFillArea.Back.ColorEms.g = float (aBack.EmissiveColor().Green());
653 ContextFillArea.Back.ColorEms.b = float (aBack.EmissiveColor().Blue());
654
655 ContextFillArea.Back.EnvReflexion = float (aBack.EnvReflexion());
656
657 // Front Material
658 const Graphic3d_MaterialAspect& aFront = theAspFill->FrontMaterial();
659 // Light specificity
660 ContextFillArea.Front.Shininess = float (aFront.Shininess());
661 ContextFillArea.Front.Ambient = float (aFront.Ambient());
662 ContextFillArea.Front.Diffuse = float (aFront.Diffuse());
663 ContextFillArea.Front.Specular = float (aFront.Specular());
664 ContextFillArea.Front.Transparency = float (aFront.Transparency());
665 ContextFillArea.Front.Emission = float (aFront.Emissive());
666
667 // Reflection mode
668 ContextFillArea.Front.IsAmbient = aFront.ReflectionMode (Graphic3d_TOR_AMBIENT) ? 1 : 0;
669 ContextFillArea.Front.IsDiffuse = aFront.ReflectionMode (Graphic3d_TOR_DIFFUSE) ? 1 : 0;
670 ContextFillArea.Front.IsSpecular = aFront.ReflectionMode (Graphic3d_TOR_SPECULAR) ? 1 : 0;
671 ContextFillArea.Front.IsEmission = aFront.ReflectionMode (Graphic3d_TOR_EMISSION) ? 1 : 0;
672
673 // Material type
674 ContextFillArea.Front.IsPhysic = aFront.MaterialType (Graphic3d_MATERIAL_PHYSIC) ? 1 : 0;
675
676 // Specular color
677 ContextFillArea.Front.ColorSpec.r = float (aFront.SpecularColor().Red());
678 ContextFillArea.Front.ColorSpec.g = float (aFront.SpecularColor().Green());
679 ContextFillArea.Front.ColorSpec.b = float (aFront.SpecularColor().Blue());
680
681 // Ambient color
682 ContextFillArea.Front.ColorAmb.r = float (aFront.AmbientColor().Red());
683 ContextFillArea.Front.ColorAmb.g = float (aFront.AmbientColor().Green());
684 ContextFillArea.Front.ColorAmb.b = float (aFront.AmbientColor().Blue());
685
686 // Diffuse color
687 ContextFillArea.Front.ColorDif.r = float (aFront.DiffuseColor().Red());
688 ContextFillArea.Front.ColorDif.g = float (aFront.DiffuseColor().Green());
689 ContextFillArea.Front.ColorDif.b = float (aFront.DiffuseColor().Blue());
690
691 // Emissive color
692 ContextFillArea.Front.ColorEms.r = float (aFront.EmissiveColor().Red());
693 ContextFillArea.Front.ColorEms.g = float (aFront.EmissiveColor().Green());
694 ContextFillArea.Front.ColorEms.b = float (aFront.EmissiveColor().Blue());
695
696 ContextFillArea.Front.EnvReflexion = float (aFront.EnvReflexion());
697
698 ContextFillArea.IsDef = 1; // Material definition ok
699
700 ContextFillArea.Texture.TextureMap = theAspFill->TextureMap();
701 ContextFillArea.Texture.doTextureMap = theAspFill->TextureMapState() ? 1 : 0;
702
703 Standard_Integer aPolyMode;
704 Standard_ShortReal aPolyFactor, aPolyUnits;
705 theAspFill->PolygonOffsets (aPolyMode, aPolyFactor, aPolyUnits);
706 ContextFillArea.PolygonOffsetMode = aPolyMode;
707 ContextFillArea.PolygonOffsetFactor = aPolyFactor;
708 ContextFillArea.PolygonOffsetUnits = aPolyUnits;
709
710 ContextFillArea.ShaderProgram = theAspFill->ShaderProgram();
711
712 UpdateAspectFace (Standard_False);
713
714 ContextFillArea.IsSet = 1;
715
716 Update();
717}
718
719// =======================================================================
720// function : SetPrimitivesAspect
721// purpose :
722// =======================================================================
723void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
724{
725 if (IsDeleted())
726 {
727 return;
728 }
729
730 Standard_Real aScale;
731 Quantity_Color aColor;
732 Aspect_TypeOfMarker aMarkerType;
733 theAspMarker->Values (aColor, aMarkerType, aScale);
734
735 ContextMarker.IsDef = 1;
736 ContextMarker.Color.r = Standard_ShortReal (aColor.Red());
737 ContextMarker.Color.g = Standard_ShortReal (aColor.Green());
738 ContextMarker.Color.b = Standard_ShortReal (aColor.Blue());
739 ContextMarker.MarkerType = aMarkerType;
740 ContextMarker.Scale = Standard_ShortReal (aScale);
741 ContextMarker.MarkerImage = theAspMarker->GetMarkerImage();
742
743 ContextMarker.ShaderProgram = theAspMarker->ShaderProgram();
744
745 UpdateAspectMarker (Standard_False);
746
747 ContextMarker.IsSet = 1;
748
749 Update();
750}
751
752// =======================================================================
753// function : SetPrimitivesAspect
754// purpose :
755// =======================================================================
756void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
757{
758 if (IsDeleted())
759 {
760 return;
761 }
762
763 Standard_CString aFont;
764 Standard_Real aSpace, anExpansion, aTextAngle;
765 Quantity_Color aColor, aColorSubTitle;
766 Aspect_TypeOfStyleText aStyle;
767 Aspect_TypeOfDisplayText aDisplayType;
768 Standard_Boolean aTextZoomable;
769 Font_FontAspect aTextFontAspect;
770 theAspText->Values (aColor, aFont, anExpansion, aSpace, aStyle, aDisplayType,
771 aColorSubTitle, aTextZoomable, aTextAngle, aTextFontAspect);
772
773 ContextText.IsDef = 1;
774 ContextText.Color.r = float (aColor.Red());
775 ContextText.Color.g = float (aColor.Green());
776 ContextText.Color.b = float (aColor.Blue());
777 ContextText.Font = (char* )aFont;
778 ContextText.Expan = float (anExpansion);
779 ContextText.Space = float (aSpace);
780 ContextText.Style = aStyle;
781 ContextText.DisplayType = aDisplayType;
782 ContextText.ColorSubTitle.r = float (aColorSubTitle.Red());
783 ContextText.ColorSubTitle.g = float (aColorSubTitle.Green());
784 ContextText.ColorSubTitle.b = float (aColorSubTitle.Blue());
785 ContextText.TextZoomable = aTextZoomable;
786 ContextText.TextAngle = float (aTextAngle);
787 ContextText.TextFontAspect = aTextFontAspect;
788 ContextText.ShaderProgram = theAspText->ShaderProgram();
789
790 UpdateAspectText (Standard_False);
791
792 ContextText.IsSet = 1;
793
794 Update();
795}
796
797// =======================================================================
798// function : IsGroupPrimitivesAspectSet
799// purpose :
800// =======================================================================
801Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const
802{
803 switch (theAspect)
804 {
805 case Graphic3d_ASPECT_LINE: return ContextLine.IsSet;
806 case Graphic3d_ASPECT_TEXT: return ContextText.IsSet;
807 case Graphic3d_ASPECT_MARKER: return ContextMarker.IsSet;
808 case Graphic3d_ASPECT_FILL_AREA: return ContextFillArea.IsSet;
809 default: return Standard_False;
810 }
811}
812
813// =======================================================================
814// function : GroupPrimitivesAspect
815// purpose :
816// =======================================================================
817void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
818 const Handle(Graphic3d_AspectText3d)& theAspText,
819 const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
820 const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
821{
822 Quantity_Color aColor;
823 Graphic3d_MaterialAspect aFront, aBack;
824
825 const CALL_DEF_CONTEXTLINE& anAspLine = ContextLine.IsSet ? ContextLine : myStructure->CStructure()->ContextLine;
826 aColor.SetValues (Standard_Real (anAspLine.Color.r),
827 Standard_Real (anAspLine.Color.g),
828 Standard_Real (anAspLine.Color.b), Quantity_TOC_RGB);
829 theAspLine->SetColor (aColor);
830 theAspLine->SetType (Aspect_TypeOfLine (anAspLine.LineType));
831 theAspLine->SetWidth (Standard_Real (anAspLine.Width));
832 theAspLine->SetShaderProgram (anAspLine.ShaderProgram);
833
834 const CALL_DEF_CONTEXTTEXT& anAspText = ContextText.IsSet ? ContextText : myStructure->CStructure()->ContextText;
835 aColor.SetValues (Standard_Real (anAspText.Color.r),
836 Standard_Real (anAspText.Color.g),
837 Standard_Real (anAspText.Color.b), Quantity_TOC_RGB);
838 theAspText->SetColor (aColor);
839 aColor.SetValues (Standard_Real (anAspText.ColorSubTitle.r),
840 Standard_Real (anAspText.ColorSubTitle.g),
841 Standard_Real (anAspText.ColorSubTitle.b), Quantity_TOC_RGB);
842 theAspText->SetColorSubTitle (aColor);
843 theAspText->SetFont (anAspText.Font);
844 theAspText->SetSpace (Standard_Real (anAspText.Space));
845 theAspText->SetExpansionFactor (Standard_Real (anAspText.Expan));
846 theAspText->SetStyle (Aspect_TypeOfStyleText (anAspText.Style));
847 theAspText->SetDisplayType (Aspect_TypeOfDisplayText (anAspText.DisplayType));
848 theAspText->SetShaderProgram (anAspText.ShaderProgram);
849
850 const CALL_DEF_CONTEXTMARKER& anAspMarker = ContextMarker.IsSet ? ContextMarker : myStructure->CStructure()->ContextMarker;
851 aColor.SetValues (Standard_Real (anAspMarker.Color.r),
852 Standard_Real (anAspMarker.Color.g),
853 Standard_Real (anAspMarker.Color.b), Quantity_TOC_RGB);
854 theAspMarker->SetColor (aColor);
855 theAspMarker->SetType (anAspMarker.MarkerType);
856 theAspMarker->SetScale (Standard_Real (anAspMarker.Scale));
857 theAspMarker->SetShaderProgram (anAspMarker.ShaderProgram);
858 if (anAspMarker.MarkerType == Aspect_TOM_USERDEFINED)
859 {
860 theAspMarker->SetMarkerImage (ContextMarker.MarkerImage);
861 }
862
863 const CALL_DEF_CONTEXTFILLAREA& anAspFill = ContextFillArea.IsSet ? ContextFillArea : myStructure->CStructure()->ContextFillArea;
864 // Interior
865 theAspFill->SetInteriorStyle (Aspect_InteriorStyle (anAspFill.Style));
866 aColor.SetValues (Standard_Real (anAspFill.IntColor.r),
867 Standard_Real (anAspFill.IntColor.g),
868 Standard_Real (anAspFill.IntColor.b), Quantity_TOC_RGB);
869 theAspFill->SetInteriorColor (aColor);
870
871 // Edges
872 aColor.SetValues (Standard_Real (anAspFill.EdgeColor.r),
873 Standard_Real (anAspFill.EdgeColor.g),
874 Standard_Real (anAspFill.EdgeColor.b), Quantity_TOC_RGB);
875 theAspFill->SetEdgeColor (aColor);
876 theAspFill->SetEdgeLineType (Aspect_TypeOfLine (anAspFill.LineType));
877 theAspFill->SetEdgeWidth (Standard_Real (anAspFill.Width));
878
879 // Back Material
880 aBack.SetShininess (Standard_Real (anAspFill.Back.Shininess));
881 aBack.SetAmbient (Standard_Real (anAspFill.Back.Ambient));
882 aBack.SetDiffuse (Standard_Real (anAspFill.Back.Diffuse));
883 aBack.SetSpecular (Standard_Real (anAspFill.Back.Specular));
884 aBack.SetTransparency (Standard_Real (anAspFill.Back.Transparency));
885 aBack.SetEmissive (Standard_Real (anAspFill.Back.Emission));
886 anAspFill.Back.IsAmbient == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_AMBIENT) : aBack.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
887 anAspFill.Back.IsDiffuse == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE) : aBack.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
888 anAspFill.Back.IsSpecular == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aBack.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
889 anAspFill.Back.IsEmission == 1 ? aBack.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aBack.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
890
891 aColor.SetValues (Standard_Real (anAspFill.Back.ColorSpec.r),
892 Standard_Real (anAspFill.Back.ColorSpec.g),
893 Standard_Real (anAspFill.Back.ColorSpec.b), Quantity_TOC_RGB);
894 aBack.SetSpecularColor (aColor);
895
896 aColor.SetValues (Standard_Real (anAspFill.Back.ColorAmb.r),
897 Standard_Real (anAspFill.Back.ColorAmb.g),
898 Standard_Real (anAspFill.Back.ColorAmb.b), Quantity_TOC_RGB);
899 aBack.SetAmbientColor (aColor);
900
901 aColor.SetValues (Standard_Real (anAspFill.Back.ColorDif.r),
902 Standard_Real (anAspFill.Back.ColorDif.g),
903 Standard_Real (anAspFill.Back.ColorDif.b), Quantity_TOC_RGB);
904 aBack.SetDiffuseColor (aColor);
905
906 aColor.SetValues (Standard_Real (anAspFill.Back.ColorEms.r),
907 Standard_Real (anAspFill.Back.ColorEms.g),
908 Standard_Real (anAspFill.Back.ColorEms.b), Quantity_TOC_RGB);
909 aBack.SetEmissiveColor (aColor);
910
911 aBack.SetEnvReflexion (anAspFill.Back.EnvReflexion);
912
913 // Front Material
914 aFront.SetShininess (Standard_Real (anAspFill.Front.Shininess));
915 aFront.SetAmbient (Standard_Real (anAspFill.Front.Ambient));
916 aFront.SetDiffuse (Standard_Real (anAspFill.Front.Diffuse));
917 aFront.SetSpecular (Standard_Real (anAspFill.Front.Specular));
918 aFront.SetTransparency (Standard_Real (anAspFill.Front.Transparency));
919 aFront.SetEmissive (Standard_Real (anAspFill.Back.Emission));
920 anAspFill.Front.IsAmbient == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_AMBIENT) : aFront.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
921 anAspFill.Front.IsDiffuse == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_DIFFUSE) : aFront.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
922 anAspFill.Front.IsSpecular == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_SPECULAR) : aFront.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
923 anAspFill.Front.IsEmission == 1 ? aFront.SetReflectionModeOn (Graphic3d_TOR_EMISSION) : aFront.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
924
925 aColor.SetValues (Standard_Real (anAspFill.Front.ColorSpec.r),
926 Standard_Real (anAspFill.Front.ColorSpec.g),
927 Standard_Real (anAspFill.Front.ColorSpec.b), Quantity_TOC_RGB);
928 aFront.SetSpecularColor (aColor);
929
930 aColor.SetValues (Standard_Real (anAspFill.Front.ColorAmb.r),
931 Standard_Real (anAspFill.Front.ColorAmb.g),
932 Standard_Real (anAspFill.Front.ColorAmb.b), Quantity_TOC_RGB);
933 aFront.SetAmbientColor (aColor);
934
935 aColor.SetValues (Standard_Real (anAspFill.Front.ColorDif.r),
936 Standard_Real (anAspFill.Front.ColorDif.g),
937 Standard_Real (anAspFill.Front.ColorDif.b), Quantity_TOC_RGB);
938 aFront.SetDiffuseColor (aColor);
939
940 aColor.SetValues (Standard_Real (anAspFill.Front.ColorEms.r),
941 Standard_Real (anAspFill.Front.ColorEms.g),
942 Standard_Real (anAspFill.Front.ColorEms.b), Quantity_TOC_RGB);
943 aFront.SetEmissiveColor (aColor);
944
945 aFront.SetEnvReflexion (anAspFill.Front.EnvReflexion);
946
947 // Edges
948 anAspFill.Edge == 1 ? theAspFill->SetEdgeOn() : theAspFill->SetEdgeOff();
949 // Hatch
950 theAspFill->SetHatchStyle (Aspect_HatchStyle (anAspFill.Hatch));
951 // Materials
952 // Front and Back face
953 anAspFill.Distinguish == 1 ? theAspFill->SetDistinguishOn() : theAspFill->SetDistinguishOff();
954 anAspFill.BackFace == 1 ? theAspFill->SuppressBackFace() : theAspFill->AllowBackFace();
955 // Texture
956 theAspFill->SetTextureMap (anAspFill.Texture.TextureMap);
957 anAspFill.Texture.doTextureMap == 1 ? theAspFill->SetTextureMapOn() : theAspFill->SetTextureMapOff();
958 theAspFill->SetShaderProgram (anAspFill.ShaderProgram);
959 theAspFill->SetPolygonOffsets (anAspFill.PolygonOffsetMode,
960 anAspFill.PolygonOffsetFactor,
961 anAspFill.PolygonOffsetUnits);
962 theAspFill->SetBackMaterial (aBack);
963 theAspFill->SetFrontMaterial (aFront);
964}
965
966// =======================================================================
967// function : PrimitivesAspect
968// purpose :
969// =======================================================================
970void Graphic3d_Group::PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
971 const Handle(Graphic3d_AspectText3d)& theAspText,
972 const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
973 const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
974{
975 GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill);
976}
977
978// =======================================================================
979// function : AddPrimitiveArray
980// purpose :
981// =======================================================================
982void Graphic3d_Group::AddPrimitiveArray (const Handle(Graphic3d_ArrayOfPrimitives)& thePrim,
983 const Standard_Boolean theToEvalMinMax)
984{
985 if (IsDeleted()
986 || !thePrim->IsValid())
987 {
988 return;
989 }
990
991 if (!MyContainsFacet
992 && thePrim->Type() != Graphic3d_TOPA_POLYLINES
993 && thePrim->Type() != Graphic3d_TOPA_SEGMENTS
994 && thePrim->Type() != Graphic3d_TOPA_POINTS)
995 {
996 myStructure->GroupsWithFacet (1);
997 MyContainsFacet = Standard_True;
998 }
999
1000 MyIsEmpty = Standard_False;
1001 myListOfPArray.Append (thePrim);
1002 if (theToEvalMinMax)
1003 {
1004 Standard_Real x, y, z;
1005 const Standard_Integer aNbVerts = thePrim->VertexNumber();
1006 for (Standard_Integer aVertIter = 1; aVertIter <= aNbVerts; ++aVertIter)
1007 {
1008 thePrim->Vertice (aVertIter, x, y, z);
1009 if (x < myBounds.XMin) myBounds.XMin = Standard_ShortReal (x);
1010 if (y < myBounds.YMin) myBounds.YMin = Standard_ShortReal (y);
1011 if (z < myBounds.ZMin) myBounds.ZMin = Standard_ShortReal (z);
1012 if (x > myBounds.XMax) myBounds.XMax = Standard_ShortReal (x);
1013 if (y > myBounds.YMax) myBounds.YMax = Standard_ShortReal (y);
1014 if (z > myBounds.ZMax) myBounds.ZMax = Standard_ShortReal (z);
1015 }
1016 }
1017
1018 Update();
1019}
1020
1021// =======================================================================
1022// function : Marker
1023// purpose :
1024// =======================================================================
1025void Graphic3d_Group::Marker (const Graphic3d_Vertex& thePoint,
1026 const Standard_Boolean theToEvalMinMax)
1027{
1028 Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (1);
1029 aPoints->AddVertex (thePoint.X(), thePoint.Y(), thePoint.Z());
1030 AddPrimitiveArray (aPoints, theToEvalMinMax);
1031}
1032
1033// =======================================================================
1034// function : UserDraw
1035// purpose :
1036// =======================================================================
1037void Graphic3d_Group::UserDraw (const Standard_Address /*theObject*/,
1038 const Standard_Boolean /*theToEvalMinMax*/,
1039 const Standard_Boolean theContainsFacet)
1040{
1041 if (IsDeleted())
1042 {
1043 return;
1044 }
1045
1046 // Without this modification, the group assumes the primitive contains
1047 // no polygons and does not require the Z-buffer for display.
1048 if (!MyContainsFacet && theContainsFacet)
1049 {
1050 myStructure->GroupsWithFacet (1);
1051 MyContainsFacet = Standard_True;
1052 }
1053
1054 MyIsEmpty = Standard_False;
1055 Update();
1056}
1057
1058// =======================================================================
1059// function : Text
1060// purpose :
1061// =======================================================================
1062void Graphic3d_Group::Text (const Standard_CString /*theText*/,
1063 const Graphic3d_Vertex& thePoint,
1064 const Standard_Real /*theHeight*/,
1065 const Quantity_PlaneAngle /*theAngle*/,
1066 const Graphic3d_TextPath /*theTp*/,
1067 const Graphic3d_HorizontalTextAlignment /*theHta*/,
1068 const Graphic3d_VerticalTextAlignment /*theVta*/,
1069 const Standard_Boolean theToEvalMinMax)
1070{
1071 if (IsDeleted())
1072 {
1073 return;
1074 }
1075
1076 MyIsEmpty = Standard_False;
1077 if (theToEvalMinMax)
1078 {
1079 Standard_ShortReal x, y, z;
1080 thePoint.Coord (x, y, z);
1081 if (x < myBounds.XMin) myBounds.XMin = x;
1082 if (y < myBounds.YMin) myBounds.YMin = y;
1083 if (z < myBounds.ZMin) myBounds.ZMin = z;
1084 if (x > myBounds.XMax) myBounds.XMax = x;
1085 if (y > myBounds.YMax) myBounds.YMax = y;
1086 if (z > myBounds.ZMax) myBounds.ZMax = z;
1087 }
1088 Update();
1089}
1090
1091// =======================================================================
1092// function : Text
1093// purpose :
1094// =======================================================================
1095void Graphic3d_Group::Text (const Standard_CString theText,
1096 const Graphic3d_Vertex& thePoint,
1097 const Standard_Real theHeight,
1098 const Standard_Boolean theToEvalMinMax)
1099{
1100 Text (theText, thePoint, theHeight, 0.0,
1101 Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
1102}
1103
1104// =======================================================================
1105// function : Text
1106// purpose :
1107// =======================================================================
1108void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
1109 const Graphic3d_Vertex& thePoint,
1110 const Standard_Real theHeight,
1111 const Quantity_PlaneAngle theAngle,
1112 const Graphic3d_TextPath theTp,
1113 const Graphic3d_HorizontalTextAlignment theHta,
1114 const Graphic3d_VerticalTextAlignment theVta,
1115 const Standard_Boolean theToEvalMinMax)
1116{
1117 const NCollection_String aText ((Standard_Utf16Char* )theText.ToExtString());
1118 Text (aText.ToCString(), thePoint, theHeight, theAngle,
1119 theTp, theHta, theVta, theToEvalMinMax);
1120}
1121
1122// =======================================================================
1123// function : Text
1124// purpose :
1125// =======================================================================
1126void Graphic3d_Group::Text (const TCollection_ExtendedString& theText,
1127 const Graphic3d_Vertex& thePoint,
1128 const Standard_Real theHeight,
1129 const Standard_Boolean theToEvalMinMax)
1130{
1131 const NCollection_String aText ((Standard_Utf16Char* )theText.ToExtString());
1132 Text (aText.ToCString(), thePoint, theHeight, 0.0,
1133 Graphic3d_TP_RIGHT, Graphic3d_HTA_LEFT, Graphic3d_VTA_BOTTOM, theToEvalMinMax);
7fd59977 1134}