0024704: Visualization - inherit OpenGl_Structure from Graphic3d_CStructure
[occt.git] / src / Graphic3d / Graphic3d_Group_1.cxx
1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //-Version      
17
18 //-Design       Declaration des variables specifiques aux groupes
19 //              de primitives
20
21 //-Warning      Un groupe est defini dans une structure
22 //              Il s'agit de la plus petite entite editable
23
24 //-References   
25
26 //-Language     C++ 2.0
27
28 //-Declarations
29
30 // for the class
31 #include <Graphic3d_Group.jxx>
32 #include <Graphic3d_Group.pxx>
33
34 //-Methods, in order
35
36 void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
37 {
38   if (IsDeleted ()) return;
39
40   MyCGroup.ContextLine.IsSet     = 0,
41   MyCGroup.ContextText.IsSet     = 0,
42   MyCGroup.ContextMarker.IsSet   = 0,
43   MyCGroup.ContextFillArea.IsSet = 0;
44
45   MyCGroup.ContextLine.IsDef     = 0,
46   MyCGroup.ContextText.IsDef     = 0,
47   MyCGroup.ContextMarker.IsDef   = 0,
48   MyCGroup.ContextFillArea.IsDef = 0;
49
50   MyCGroup.PickId.IsDef = 0,
51   MyCGroup.PickId.IsSet = 0,
52   MyCGroup.PickId.Value = 0;
53
54   MyBounds.XMin = ShortRealLast (),
55   MyBounds.YMin = ShortRealLast (),
56   MyBounds.ZMin = ShortRealLast ();
57
58   MyBounds.XMax = ShortRealFirst (),
59   MyBounds.YMax = ShortRealFirst (),
60   MyBounds.ZMax = ShortRealFirst ();
61
62   if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
63   MyContainsFacet = Standard_False,
64   MyIsEmpty       = Standard_True;
65
66   MyGraphicDriver->ClearGroup (MyCGroup);
67
68   // clear method could be used on Graphic3d_Structure destruction,
69   // and its structure manager could be already destroyed, in that
70   // case we don't need to update it;
71   if (theUpdateStructureMgr)
72     Update ();
73 }
74
75 void Graphic3d_Group::Destroy ()
76 {
77   // tell graphics driver to clear internal resources of the group
78   if (!IsEmpty () && !MyGraphicDriver.IsNull ())
79     MyGraphicDriver->ClearGroup (MyCGroup);
80
81 }
82
83 void Graphic3d_Group::Remove ()
84 {
85         if (IsDeleted ()) return;
86
87         MyGraphicDriver->RemoveGroup (MyCGroup);
88         MyStructure->Remove (this);
89         MyCGroup.ptrGroup       = NULL;
90
91         Update ();
92
93         MyBounds.XMin   = ShortRealLast (),
94         MyBounds.YMin   = ShortRealLast (),
95         MyBounds.ZMin   = ShortRealLast ();
96
97         MyBounds.XMax   = ShortRealFirst (),
98         MyBounds.YMax   = ShortRealFirst (),
99         MyBounds.ZMax   = ShortRealFirst ();
100
101         if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
102         MyContainsFacet = Standard_False,
103         MyIsEmpty       = Standard_True;
104 }