b311480e |
1 | // Created on: 1997-04-22 |
2 | // Created by: Guest Design |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
973c2be1 |
8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | // <g_design> |
18 | |
19 | |
20 | #include <Standard_NotImplemented.hxx> |
21 | |
22 | #include <AIS_MultipleConnectedInteractive.ixx> |
23 | |
24 | #include <PrsMgr_ModedPresentation.hxx> |
25 | #include <PrsMgr_Presentation3d.hxx> |
26 | |
27 | static Standard_Boolean IsInSeq (const AIS_SequenceOfInteractive& theSeq, |
28 | const Handle(AIS_InteractiveObject)& theItem) |
29 | { |
30 | Standard_Integer I = theSeq.Length(); |
31 | while ( I>0 && theSeq.Value(I) != theItem) { |
32 | I--; |
33 | } |
34 | return (I>0); |
35 | } |
36 | |
37 | static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq , |
38 | const Handle(AIS_InteractiveObject)& theItem) |
39 | { |
40 | Standard_Integer I = theSeq.Length(); |
41 | while ( I>0 && theSeq.Value(I) != theItem) { |
42 | I--; |
43 | } |
44 | return I; |
45 | } |
46 | |
47 | |
48 | //======================================================================= |
49 | //function : AIS_MultipleConnectedInteractive |
50 | //purpose : |
51 | //======================================================================= |
52 | |
53 | AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive |
54 | (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): |
55 | AIS_InteractiveObject(aTypeOfPresentation3d) |
56 | { |
57 | SetHilightMode(0); |
58 | } |
59 | |
60 | //======================================================================= |
61 | //function : Type |
62 | //purpose : |
63 | //======================================================================= |
64 | AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const |
65 | {return AIS_KOI_Object;} |
66 | |
67 | //======================================================================= |
68 | //function : Signature |
69 | //purpose : |
70 | //======================================================================= |
71 | Standard_Integer AIS_MultipleConnectedInteractive::Signature() const |
72 | {return 1;} |
73 | |
74 | //======================================================================= |
75 | //function : Connect |
76 | //purpose : |
77 | //======================================================================= |
78 | void AIS_MultipleConnectedInteractive::Connect(const Handle(AIS_InteractiveObject)& anotherIObj) |
79 | { |
80 | |
81 | if (!IsInSeq (myReferences, anotherIObj)) { |
82 | myReferences.Append(anotherIObj); |
83 | } |
84 | } |
85 | |
86 | //======================================================================= |
87 | //function : HasConnection |
88 | //purpose : |
89 | //======================================================================= |
90 | Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const |
91 | { |
92 | return (!myReferences.Length()==0); |
93 | } |
94 | |
95 | //======================================================================= |
96 | //function : Disconnect |
97 | //purpose : |
98 | //======================================================================= |
99 | |
100 | void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj) |
101 | { |
102 | Standard_Integer I = RangeInSeq (myReferences, anotherIObj); |
103 | if (I != 0) { |
104 | myReferences.Remove(I); |
105 | |
106 | } |
107 | } |
108 | |
109 | //======================================================================= |
110 | //function : DisconnectAll |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | void AIS_MultipleConnectedInteractive::DisconnectAll () |
115 | { |
116 | /* for(Standard_Integer i =1;i<=myPresentations.Length();i++) |
117 | { |
118 | Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation()); |
119 | if(!P.IsNull()) { |
120 | P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT); |
121 | } |
122 | }*/ |
123 | myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!! |
124 | myReferences.Clear(); |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : Compute |
792c785c |
129 | //purpose : |
7fd59977 |
130 | //======================================================================= |
792c785c |
131 | void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, |
132 | const Handle(Prs3d_Presentation)& thePrs, |
133 | const Standard_Integer theMode) |
7fd59977 |
134 | { |
792c785c |
135 | thePrs->Clear (Standard_False); |
136 | thePrs->RemoveAll(); |
137 | if (HasConnection()) |
138 | { |
139 | for (Standard_Integer aRefIter = 1; aRefIter <= myReferences.Length(); ++aRefIter) |
140 | { |
141 | const Handle (AIS_InteractiveObject)& aRef = myReferences.Value (aRefIter); |
142 | if (!aRef->HasInteractiveContext()) |
143 | { |
144 | aRef->SetContext (GetContext()); |
145 | } |
146 | |
147 | thePrsMgr->Connect (this, aRef, theMode, theMode); |
148 | if (thePrsMgr->Presentation (aRef, theMode)->MustBeUpdated()) |
149 | { |
150 | thePrsMgr->Update (aRef, theMode); |
151 | } |
7fd59977 |
152 | } |
153 | } |
154 | |
792c785c |
155 | thePrs->ReCompute(); |
7fd59977 |
156 | } |
792c785c |
157 | |
7fd59977 |
158 | //======================================================================= |
159 | //function : Compute |
160 | //purpose : |
161 | //======================================================================= |
162 | |
163 | void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, |
164 | const Handle_Prs3d_Presentation& aPresentation) |
165 | { |
166 | // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)"); |
167 | PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : Compute |
172 | //purpose : |
7fd59977 |
173 | //======================================================================= |
174 | |
175 | void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, |
176 | const Handle_Geom_Transformation& aTransformation, |
177 | const Handle_Prs3d_Presentation& aPresentation) |
178 | { |
179 | // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); |
180 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; |
181 | } |
182 | |
183 | //======================================================================= |
184 | //function : ComputeSelection |
185 | //purpose : |
186 | //======================================================================= |
187 | void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/, |
188 | const Standard_Integer /*aMode*/) |
189 | { |
190 | } |