0024818: CLang warnings -Wlogical-not-parentheses
[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-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
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_Presentation.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 aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
117     {
118       const Handle(PrsMgr_Presentation)& aPrs = myPresentations (aPrsIter).Presentation();
119       if (!aPrs.IsNull())
120       {
121         aPrs->Presentation()->DisconnectAll (Graphic3d_TOC_DESCENDANT);
122       }
123     }*/
124   myPreviousReferences = myReferences; // pour garder les poignees au chaud!!!!
125   myReferences.Clear();
126 }
127
128 //=======================================================================
129 //function : Compute
130 //purpose  :
131 //=======================================================================
132 void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
133                                                 const Handle(Prs3d_Presentation)&           thePrs,
134                                                 const Standard_Integer                      theMode)
135 {
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       }
153     }
154   }
155
156   thePrs->ReCompute();
157 }
158
159 //=======================================================================
160 //function : Compute
161 //purpose  : 
162 //=======================================================================
163
164 void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
165                                                const Handle_Prs3d_Presentation& aPresentation)
166 {
167 // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
168  PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
169 }
170
171 //=======================================================================
172 //function : Compute
173 //purpose  : 
174 //=======================================================================
175
176 void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
177                                                const Handle_Geom_Transformation& aTransformation,
178                                                const Handle_Prs3d_Presentation& aPresentation)
179 {
180 // Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
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 }