0023432: Connected Interactive Objects computed without Interactive Context
[occt.git] / src / AIS / AIS_MultipleConnectedInteractive.cxx
CommitLineData
b311480e 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
7fd59977 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
31static 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
41static 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
57AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive
58(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
59AIS_InteractiveObject(aTypeOfPresentation3d)
60{
61 SetHilightMode(0);
62}
63
64//=======================================================================
65//function : Type
66//purpose :
67//=======================================================================
68AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
69{return AIS_KOI_Object;}
70
71//=======================================================================
72//function : Signature
73//purpose :
74//=======================================================================
75Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
76{return 1;}
77
78//=======================================================================
79//function : Connect
80//purpose :
81//=======================================================================
82void 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//=======================================================================
94Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
95{
96 return (!myReferences.Length()==0);
97}
98
99//=======================================================================
100//function : Disconnect
101//purpose :
102//=======================================================================
103
104void 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
118void 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
792c785c 133//purpose :
7fd59977 134//=======================================================================
792c785c 135void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
136 const Handle(Prs3d_Presentation)& thePrs,
137 const Standard_Integer theMode)
7fd59977 138{
792c785c 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 }
7fd59977 156 }
157 }
158
792c785c 159 thePrs->ReCompute();
7fd59977 160}
792c785c 161
7fd59977 162//=======================================================================
163//function : Compute
164//purpose :
165//=======================================================================
166
167void 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
179void AIS_MultipleConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d,
180 const Handle_Graphic2d_GraphicObject& aGraphicObject,
181 const int anInteger)
182{
183// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
184 PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
185}
186
187//=======================================================================
188//function : Compute
189//purpose :
190//=======================================================================
191
192void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector,
193 const Handle_Geom_Transformation& aTransformation,
194 const Handle_Prs3d_Presentation& aPresentation)
195{
196// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
197 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
198}
199
200//=======================================================================
201//function : ComputeSelection
202//purpose :
203//=======================================================================
204void AIS_MultipleConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSel*/,
205 const Standard_Integer /*aMode*/)
206{
207}