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 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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> |
af324faa |
25 | #include <PrsMgr_Presentation.hxx> |
7fd59977 |
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 | { |
c29a9290 |
92 | return (myReferences.Length() != 0); |
7fd59977 |
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 | { |
af324faa |
116 | /* for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter) |
7fd59977 |
117 | { |
af324faa |
118 | const Handle(PrsMgr_Presentation)& aPrs = myPresentations (aPrsIter).Presentation(); |
119 | if (!aPrs.IsNull()) |
120 | { |
121 | aPrs->Presentation()->DisconnectAll (Graphic3d_TOC_DESCENDANT); |
7fd59977 |
122 | } |
123 | }*/ |
124 | myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!! |
125 | myReferences.Clear(); |
126 | } |
127 | |
128 | //======================================================================= |
129 | //function : Compute |
792c785c |
130 | //purpose : |
7fd59977 |
131 | //======================================================================= |
792c785c |
132 | void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, |
133 | const Handle(Prs3d_Presentation)& thePrs, |
134 | const Standard_Integer theMode) |
7fd59977 |
135 | { |
792c785c |
136 | thePrs->Clear (Standard_False); |
137 | thePrs->RemoveAll(); |
138 | if (HasConnection()) |
139 | { |
140 | for (Standard_Integer aRefIter = 1; aRefIter <= myReferences.Length(); ++aRefIter) |
141 | { |
142 | const Handle (AIS_InteractiveObject)& aRef = myReferences.Value (aRefIter); |
143 | if (!aRef->HasInteractiveContext()) |
144 | { |
145 | aRef->SetContext (GetContext()); |
146 | } |
147 | |
148 | thePrsMgr->Connect (this, aRef, theMode, theMode); |
149 | if (thePrsMgr->Presentation (aRef, theMode)->MustBeUpdated()) |
150 | { |
151 | thePrsMgr->Update (aRef, theMode); |
152 | } |
7fd59977 |
153 | } |
154 | } |
155 | |
792c785c |
156 | thePrs->ReCompute(); |
7fd59977 |
157 | } |
792c785c |
158 | |
7fd59977 |
159 | //======================================================================= |
160 | //function : Compute |
161 | //purpose : |
162 | //======================================================================= |
163 | |
857ffd5e |
164 | void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, |
165 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
166 | { |
857ffd5e |
167 | // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Prs3d_Presentation)&)"); |
7fd59977 |
168 | PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; |
169 | } |
170 | |
171 | //======================================================================= |
172 | //function : Compute |
173 | //purpose : |
7fd59977 |
174 | //======================================================================= |
175 | |
857ffd5e |
176 | void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector, |
177 | const Handle(Geom_Transformation)& aTransformation, |
178 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
179 | { |
857ffd5e |
180 | // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); |
7fd59977 |
181 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; |
182 | } |
183 | |
184 | //======================================================================= |
185 | //function : ComputeSelection |
186 | //purpose : |
187 | //======================================================================= |
188 | void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/, |
189 | const Standard_Integer /*aMode*/) |
190 | { |
191 | } |