summaryrefslogtreecommitdiff
path: root/src/Graphic3d/Graphic3d_Group_1.cxx
blob: 43a255ea93ddab853998868e97c4440911af278b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

#define XDESTROY

// File		Graphic3d_Group_1.cxx (Clear Remove Open Close)
// Created	Fevrier 1992
// Author	NW,JPB,CAL

//-Copyright	MatraDatavision 1991,1992

//-Version	

//-Design	Declaration des variables specifiques aux groupes
//		de primitives

//-Warning	Un groupe est defini dans une structure
//		Il s'agit de la plus petite entite editable

//-References	

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Graphic3d_Group.jxx>
#include <Graphic3d_Group.pxx>

//-Methods, in order

void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr)
{
  if (IsDeleted ()) return;

  MyCGroup.ContextLine.IsSet     = 0,
  MyCGroup.ContextText.IsSet     = 0,
  MyCGroup.ContextMarker.IsSet   = 0,
  MyCGroup.ContextFillArea.IsSet = 0;

  MyCGroup.ContextLine.IsDef     = 0,
  MyCGroup.ContextText.IsDef     = 0,
  MyCGroup.ContextMarker.IsDef   = 0,
  MyCGroup.ContextFillArea.IsDef = 0;

  MyCGroup.PickId.IsDef = 0,
  MyCGroup.PickId.IsSet = 0,
  MyCGroup.PickId.Value = 0;

  MyBounds.XMin	= ShortRealLast (),
  MyBounds.YMin	= ShortRealLast (),
  MyBounds.ZMin	= ShortRealLast ();

  MyBounds.XMax	= ShortRealFirst (),
  MyBounds.YMax	= ShortRealFirst (),
  MyBounds.ZMax	= ShortRealFirst ();

  if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
  MyContainsFacet = Standard_False,
  MyIsEmpty       = Standard_True;

  MyGraphicDriver->ClearGroup (MyCGroup);

  // clear method could be used on Graphic3d_Structure destruction,
  // and its structure manager could be already destroyed, in that
  // case we don't need to update it;
  if (theUpdateStructureMgr)
    Update ();
}

void Graphic3d_Group::Destroy () {

#ifdef DESTROY
	cout << "Graphic3d_Group::Destroy ()\n";
#endif

  // tell graphics driver to clear internal resources of the group
  if (!IsEmpty () && !MyGraphicDriver.IsNull ())
    MyGraphicDriver->ClearGroup (MyCGroup);

}

void Graphic3d_Group::Remove () {

	if (IsDeleted ()) return;

	MyCGroup.IsDeleted	= 1;
	MyGraphicDriver->RemoveGroup (MyCGroup);
	MyStructure->Remove (this);
	Update ();

	MyBounds.XMin	= ShortRealLast (),
	MyBounds.YMin	= ShortRealLast (),
	MyBounds.ZMin	= ShortRealLast ();

	MyBounds.XMax	= ShortRealFirst (),
	MyBounds.YMax	= ShortRealFirst (),
	MyBounds.ZMax	= ShortRealFirst ();

	if (MyContainsFacet) MyStructure->GroupsWithFacet (-1);
	MyContainsFacet	= Standard_False,
	MyIsEmpty	= Standard_True;

}

void Graphic3d_Group::BeginPrimitives () {

	if (IsDeleted ()) return;
	if (MyCGroup.IsOpen) return;

	MyCGroup.IsOpen	= 1;

	MyGraphicDriver->OpenGroup (MyCGroup);

}

void Graphic3d_Group::EndPrimitives () {

	if (IsDeleted ()) return;
	if (! MyCGroup.IsOpen) return;

	MyCGroup.IsOpen	= 0;

	MyGraphicDriver->CloseGroup (MyCGroup);

}

/*void Graphic3d_Group::SetTransformPersistence(  const Graphic3d_TransModeFlags& AFlag )
{
	//MyCGroup.TransformPersistenceFlag = AFlag;
}

Graphic3d_TransModeFlags Graphic3d_Group::TransformPersistence() const
{
	//return MyCGroup.TransformPersistenceFlag;
}*/