Replacing french comments by english one
[occt.git] / src / Visual3d / Visual3d_PickDescriptor.cxx
1
2 // File         Visual3d_PickDescriptor.cxx
3 // Created      Fevrier 1992
4 // Author       NW,JPB,CAL
5
6 //-Copyright    MatraDatavision 1991,1992
7
8 //-Version      
9
10 //-Design       Declaration of variables specific to the class
11 //              describing marking.
12
13 //-Warning      A return of marking is defined by :
14 //              - sequence of (Elem_Num, Pick_Id, Structure)
15 //              - depth
16
17 //-References   
18
19 //-Language     C++ 2.0
20
21 //-Declarations
22
23 // for the class
24 #include <Visual3d_PickDescriptor.ixx>
25
26 //-Aliases
27
28 //-Global data definitions
29
30 //      -- sequence reperee
31 //      MyPickPathSequence      :       HSequenceOfPickPath;
32
33 //      -- contexte picking de reperage associe
34 //      MyContext               :       ContextPick;
35
36 //-Constructors
37
38 //-Destructors
39
40 //-Methods, in order
41
42 Visual3d_PickDescriptor::Visual3d_PickDescriptor (const Visual3d_ContextPick& CTXP):
43 MyContext (CTXP) {
44
45         MyPickPathSequence      = new Visual3d_HSequenceOfPickPath ();
46
47 }
48
49 void Visual3d_PickDescriptor::AddPickPath (const Visual3d_PickPath& APickPath) {
50
51         if (MyContext.Depth () > MyPickPathSequence->Length ())
52                 MyPickPathSequence->Append (APickPath);
53
54 }
55
56 void Visual3d_PickDescriptor::Clear () {
57
58         MyPickPathSequence->Clear ();
59
60 }
61
62 Standard_Integer Visual3d_PickDescriptor::Depth () const {
63
64         return (MyPickPathSequence->Length ());
65
66 }
67
68 Handle(Graphic3d_Structure) Visual3d_PickDescriptor::TopStructure () const {
69
70 Visual3d_PickPath Result;
71
72         if (MyPickPathSequence->IsEmpty ())
73                 Visual3d_PickError::Raise ("PickDescriptor empty");
74
75         switch (MyContext.Order ()) {
76
77                 case Visual3d_TOO_TOPFIRST :
78                         // MyPickPathSequence->First returns the first
79                         // PickPath found in the sequence.
80                         Result  = MyPickPathSequence->Sequence().First ();
81                 break;
82
83                 case Visual3d_TOO_BOTTOMFIRST :
84                         // MyPickPathSequence->Last returns the last
85                         // PickPath found in the sequence.
86                         Result  = MyPickPathSequence->Sequence().Last ();
87                 break;
88
89         }
90         return (Result.StructIdentifier ());
91 }
92
93 Standard_Integer Visual3d_PickDescriptor::TopPickId () const {
94
95 Visual3d_PickPath Result;
96
97         if (MyPickPathSequence->IsEmpty ())
98                 Visual3d_PickError::Raise ("PickDescriptor empty");
99
100         switch (MyContext.Order ()) {
101
102                 case Visual3d_TOO_TOPFIRST :
103                         // MyPickPathSequence->First returns the first
104                         // PickPath found in the sequence.
105                         Result  = MyPickPathSequence->Sequence().First ();
106                 break;
107
108                 case Visual3d_TOO_BOTTOMFIRST :
109                         // MyPickPathSequence->Last returns the last
110                         // PickPath found in the sequence.
111                         Result  = MyPickPathSequence->Sequence().Last ();
112                 break;
113
114         }
115         return (Result.PickIdentifier ());
116 }
117
118 Standard_Integer Visual3d_PickDescriptor::TopElementNumber () const {
119
120 Visual3d_PickPath Result;
121
122         if (MyPickPathSequence->IsEmpty ())
123                 Visual3d_PickError::Raise ("PickDescriptor empty");
124
125         switch (MyContext.Order ()) {
126
127                 case Visual3d_TOO_TOPFIRST :
128                         // MyPickPathSequence->First returns the first
129                         // PickPath found in the sequence.
130                         Result  = MyPickPathSequence->Sequence().First ();
131                 break;
132
133                 case Visual3d_TOO_BOTTOMFIRST :
134                         // MyPickPathSequence->Last returns the last
135                         // PickPath found in the sequence.
136                         Result  = MyPickPathSequence->Sequence().Last ();
137                 break;
138
139         }
140         return (Result.ElementNumber ());
141 }
142
143 Handle(Visual3d_HSequenceOfPickPath) Visual3d_PickDescriptor::PickPath () const {
144
145         return (Handle(Visual3d_HSequenceOfPickPath)::DownCast
146                                         (MyPickPathSequence->ShallowCopy ()));
147
148 }