1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 //-Design Declaration of variables specific to the class
19 // describing marking.
21 //-Warning A return of marking is defined by :
22 // - sequence of (Elem_Num, Pick_Id, Structure)
32 #include <Visual3d_PickDescriptor.ixx>
36 //-Global data definitions
38 // -- sequence reperee
39 // MyPickPathSequence : HSequenceOfPickPath;
41 // -- contexte picking de reperage associe
42 // MyContext : ContextPick;
50 Visual3d_PickDescriptor::Visual3d_PickDescriptor (const Visual3d_ContextPick& CTXP):
53 MyPickPathSequence = new Visual3d_HSequenceOfPickPath ();
57 void Visual3d_PickDescriptor::AddPickPath (const Visual3d_PickPath& APickPath) {
59 if (MyContext.Depth () > MyPickPathSequence->Length ())
60 MyPickPathSequence->Append (APickPath);
64 void Visual3d_PickDescriptor::Clear () {
66 MyPickPathSequence->Clear ();
70 Standard_Integer Visual3d_PickDescriptor::Depth () const {
72 return (MyPickPathSequence->Length ());
76 Handle(Graphic3d_Structure) Visual3d_PickDescriptor::TopStructure () const {
78 Visual3d_PickPath Result;
80 if (MyPickPathSequence->IsEmpty ())
81 Visual3d_PickError::Raise ("PickDescriptor empty");
83 switch (MyContext.Order ()) {
85 case Visual3d_TOO_TOPFIRST :
86 // MyPickPathSequence->First returns the first
87 // PickPath found in the sequence.
88 Result = MyPickPathSequence->Sequence().First ();
91 case Visual3d_TOO_BOTTOMFIRST :
92 // MyPickPathSequence->Last returns the last
93 // PickPath found in the sequence.
94 Result = MyPickPathSequence->Sequence().Last ();
98 return (Result.StructIdentifier ());
101 Standard_Integer Visual3d_PickDescriptor::TopPickId () const {
103 Visual3d_PickPath Result;
105 if (MyPickPathSequence->IsEmpty ())
106 Visual3d_PickError::Raise ("PickDescriptor empty");
108 switch (MyContext.Order ()) {
110 case Visual3d_TOO_TOPFIRST :
111 // MyPickPathSequence->First returns the first
112 // PickPath found in the sequence.
113 Result = MyPickPathSequence->Sequence().First ();
116 case Visual3d_TOO_BOTTOMFIRST :
117 // MyPickPathSequence->Last returns the last
118 // PickPath found in the sequence.
119 Result = MyPickPathSequence->Sequence().Last ();
123 return (Result.PickIdentifier ());
126 Standard_Integer Visual3d_PickDescriptor::TopElementNumber () const {
128 Visual3d_PickPath Result;
130 if (MyPickPathSequence->IsEmpty ())
131 Visual3d_PickError::Raise ("PickDescriptor empty");
133 switch (MyContext.Order ()) {
135 case Visual3d_TOO_TOPFIRST :
136 // MyPickPathSequence->First returns the first
137 // PickPath found in the sequence.
138 Result = MyPickPathSequence->Sequence().First ();
141 case Visual3d_TOO_BOTTOMFIRST :
142 // MyPickPathSequence->Last returns the last
143 // PickPath found in the sequence.
144 Result = MyPickPathSequence->Sequence().Last ();
148 return (Result.ElementNumber ());
151 Handle(Visual3d_HSequenceOfPickPath) Visual3d_PickDescriptor::PickPath () const {
153 return (Handle(Visual3d_HSequenceOfPickPath)::DownCast
154 (MyPickPathSequence->ShallowCopy ()));