0024153: Adding OpenCL to OCCT prerequisites
[occt.git] / src / AIS / AIS_MultipleConnectedInteractive.cxx
1 // Created on: 1997-04-22
2 // Created by: Guest Design
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21 //              <g_design>
22
23
24 #include <Standard_NotImplemented.hxx>
25
26 #include <AIS_MultipleConnectedInteractive.ixx>
27
28 #include <PrsMgr_ModedPresentation.hxx>
29 #include <PrsMgr_Presentation3d.hxx>
30
31 static Standard_Boolean IsInSeq (const AIS_SequenceOfInteractive&      theSeq,
32                                  const Handle(AIS_InteractiveObject)&  theItem) 
33 {
34   Standard_Integer I = theSeq.Length();
35   while ( I>0 && theSeq.Value(I) != theItem) {    
36     I--;
37   }
38   return (I>0);
39 }
40
41 static Standard_Integer RangeInSeq (const AIS_SequenceOfInteractive& theSeq ,
42                                     const Handle(AIS_InteractiveObject)&     theItem) 
43 {
44   Standard_Integer I = theSeq.Length();
45   while ( I>0 && theSeq.Value(I) != theItem) {    
46     I--;
47   }
48   return I;
49 }
50
51
52 //=======================================================================
53 //function : AIS_MultipleConnectedInteractive
54 //purpose  : 
55 //=======================================================================
56
57 AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive
58 (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
59 AIS_InteractiveObject(aTypeOfPresentation3d)
60 {    
61   SetHilightMode(0);
62 }
63
64 //=======================================================================
65 //function : Type
66 //purpose  : 
67 //=======================================================================
68 AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
69 {return AIS_KOI_Object;}
70
71 //=======================================================================
72 //function : Signature
73 //purpose  : 
74 //=======================================================================
75 Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
76 {return 1;}
77
78 //=======================================================================
79 //function : Connect
80 //purpose  : 
81 //=======================================================================
82 void AIS_MultipleConnectedInteractive::Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
83 {
84
85   if (!IsInSeq (myReferences, anotherIObj)) {
86     myReferences.Append(anotherIObj);
87   }
88 }
89
90 //=======================================================================
91 //function : HasConnection
92 //purpose  : 
93 //=======================================================================
94 Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const 
95 {
96   return (!myReferences.Length()==0);
97 }
98
99 //=======================================================================
100 //function : Disconnect
101 //purpose  : 
102 //=======================================================================
103
104 void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
105 {
106   Standard_Integer I = RangeInSeq (myReferences, anotherIObj);
107   if (I != 0) {
108     myReferences.Remove(I);
109     
110   }
111 }
112
113 //=======================================================================
114 //function : DisconnectAll
115 //purpose  : 
116 //=======================================================================
117
118 void AIS_MultipleConnectedInteractive::DisconnectAll ()
119 {
120 /*  for(Standard_Integer i =1;i<=myPresentations.Length();i++)
121     {
122       Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
123       if(!P.IsNull()) {
124         P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
125       }
126     }*/
127   myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!!
128   myReferences.Clear();
129 }
130
131 //=======================================================================
132 //function : Compute
133 //purpose  :
134 //=======================================================================
135 void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
136                                                 const Handle(Prs3d_Presentation)&           thePrs,
137                                                 const Standard_Integer                      theMode)
138 {
139   thePrs->Clear (Standard_False);
140   thePrs->RemoveAll();
141   if (HasConnection())
142   {
143     for (Standard_Integer aRefIter = 1; aRefIter <= myReferences.Length(); ++aRefIter)
144     {
145       const Handle (AIS_InteractiveObject)& aRef = myReferences.Value (aRefIter);
146       if (!aRef->HasInteractiveContext())
147       {
148         aRef->SetContext (GetContext());
149       }
150
151       thePrsMgr->Connect (this, aRef, theMode, theMode);
152       if (thePrsMgr->Presentation (aRef, theMode)->MustBeUpdated())
153       {
154         thePrsMgr->Update (aRef, theMode);
155       }
156     }
157   }
158
159   thePrs->ReCompute();
160 }
161
162 //=======================================================================
163 //function : Compute
164 //purpose  : 
165 //=======================================================================
166
167 void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
168                                                const Handle_Prs3d_Presentation& aPresentation)
169 {
170 // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
171  PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
172 }
173
174 //=======================================================================
175 //function : Compute
176 //purpose  : 
177 //=======================================================================
178
179 void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
180                                                const Handle_Geom_Transformation& aTransformation,
181                                                const Handle_Prs3d_Presentation& aPresentation)
182 {
183 // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
184  PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
185 }
186
187 //=======================================================================
188 //function : ComputeSelection
189 //purpose  : 
190 //=======================================================================
191 void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/,
192                                                         const Standard_Integer /*aMode*/)
193 {
194 }