summaryrefslogtreecommitdiff
path: root/src/Visual3d/Visual3d_PickDescriptor.cxx
blob: 95771393270ea7d6c1be0623cda4cc919aa098cc (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148

// File		Visual3d_PickDescriptor.cxx
// Created	Fevrier 1992
// Author	NW,JPB,CAL

//-Copyright	MatraDatavision 1991,1992

//-Version	

//-Design	Declaration of variables specific to the class
//		describing marking.

//-Warning	A return of marking is defined by :
//		- sequence of (Elem_Num, Pick_Id, Structure)
//		- depth

//-References	

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Visual3d_PickDescriptor.ixx>

//-Aliases

//-Global data definitions

//	-- sequence reperee
//	MyPickPathSequence	:	HSequenceOfPickPath;

//	-- contexte picking de reperage associe
//	MyContext		:	ContextPick;

//-Constructors

//-Destructors

//-Methods, in order

Visual3d_PickDescriptor::Visual3d_PickDescriptor (const Visual3d_ContextPick& CTXP):
MyContext (CTXP) {

	MyPickPathSequence	= new Visual3d_HSequenceOfPickPath ();

}

void Visual3d_PickDescriptor::AddPickPath (const Visual3d_PickPath& APickPath) {

	if (MyContext.Depth () > MyPickPathSequence->Length ())
		MyPickPathSequence->Append (APickPath);

}

void Visual3d_PickDescriptor::Clear () {

	MyPickPathSequence->Clear ();

}

Standard_Integer Visual3d_PickDescriptor::Depth () const {

	return (MyPickPathSequence->Length ());

}

Handle(Graphic3d_Structure) Visual3d_PickDescriptor::TopStructure () const {

Visual3d_PickPath Result;

	if (MyPickPathSequence->IsEmpty ())
		Visual3d_PickError::Raise ("PickDescriptor empty");

	switch (MyContext.Order ()) {

		case Visual3d_TOO_TOPFIRST :
			// MyPickPathSequence->First returns the first
			// PickPath found in the sequence.
			Result	= MyPickPathSequence->Sequence().First ();
		break;

		case Visual3d_TOO_BOTTOMFIRST :
			// MyPickPathSequence->Last returns the last
			// PickPath found in the sequence.
			Result	= MyPickPathSequence->Sequence().Last ();
		break;

	}
	return (Result.StructIdentifier ());
}

Standard_Integer Visual3d_PickDescriptor::TopPickId () const {

Visual3d_PickPath Result;

	if (MyPickPathSequence->IsEmpty ())
		Visual3d_PickError::Raise ("PickDescriptor empty");

	switch (MyContext.Order ()) {

		case Visual3d_TOO_TOPFIRST :
			// MyPickPathSequence->First returns the first
			// PickPath found in the sequence.
			Result	= MyPickPathSequence->Sequence().First ();
		break;

		case Visual3d_TOO_BOTTOMFIRST :
			// MyPickPathSequence->Last returns the last
			// PickPath found in the sequence.
			Result	= MyPickPathSequence->Sequence().Last ();
		break;

	}
	return (Result.PickIdentifier ());
}

Standard_Integer Visual3d_PickDescriptor::TopElementNumber () const {

Visual3d_PickPath Result;

	if (MyPickPathSequence->IsEmpty ())
		Visual3d_PickError::Raise ("PickDescriptor empty");

	switch (MyContext.Order ()) {

		case Visual3d_TOO_TOPFIRST :
			// MyPickPathSequence->First returns the first
			// PickPath found in the sequence.
			Result	= MyPickPathSequence->Sequence().First ();
		break;

		case Visual3d_TOO_BOTTOMFIRST :
			// MyPickPathSequence->Last returns the last
			// PickPath found in the sequence.
			Result	= MyPickPathSequence->Sequence().Last ();
		break;

	}
	return (Result.ElementNumber ());
}

Handle(Visual3d_HSequenceOfPickPath) Visual3d_PickDescriptor::PickPath () const {

	return (Handle(Visual3d_HSequenceOfPickPath)::DownCast
					(MyPickPathSequence->ShallowCopy ()));

}