0023361: Bug in gp_Trsf::Multiply
[occt.git] / src / AIS / AIS_ConnectedInteractive.cxx
CommitLineData
b311480e 1// Created on: 1997-01-08
2// Created by: Robert COUBLANC
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
22
23#include <Standard_NotImplemented.hxx>
24
25#include <AIS_ConnectedInteractive.ixx>
26#include <SelectMgr_EntityOwner.hxx>
27#include <Select3D_SensitiveEntity.hxx>
28#include <Geom_Transformation.hxx>
29
30#include <PrsMgr_ModedPresentation.hxx>
31#include <PrsMgr_Presentation3d.hxx>
32#include <OSD_Timer.hxx>
33
34
35//=======================================================================
36//function : AIS_ConnectedInteractive
37//purpose :
38//=======================================================================
39AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
40AIS_InteractiveObject(aTypeOfPresentation3d)
41{
42 SetHilightMode(0);
43}
44
45//=======================================================================
46//function : Type
47//purpose :
48//=======================================================================
49AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
50{return AIS_KOI_Object;}
51
52Standard_Integer AIS_ConnectedInteractive::Signature() const
53{return 0; }
54
55
56
57
58//=======================================================================
59//function : Connect
60//purpose :
61//=======================================================================
62void AIS_ConnectedInteractive::
63Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
64{
81bba717 65 // To have the time to Disconnect below,
66 // the old is kept for a while.
7fd59977 67 if(myReference==anotherIObj) return;
68 myOldReference = myReference;
69//Disconnect();
70 myReference = anotherIObj ;
71}
72
73//=======================================================================
74//function : Connect
75//purpose :
76//=======================================================================
77void AIS_ConnectedInteractive::
78Connect(const Handle(AIS_InteractiveObject)& anotherIobj,
79 const TopLoc_Location& aLocation)
80{
81 if(myLocation!=aLocation)
82 myLocation = aLocation;
83 if(myReference!=anotherIobj) {
81bba717 84 myOldReference = myReference; // necessary to disconnect below..
7fd59977 85// Disconnect();
86 myReference = anotherIobj;}
87
88}
89
90
91//=======================================================================
92//function : Disconnect
93//purpose :
94//=======================================================================
95
96void AIS_ConnectedInteractive::Disconnect()
97{
98 for(Standard_Integer i =1;i<=myPresentations.Length();i++)
99 {
100 Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
101 if(!P.IsNull()) {
102 P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
103 }
104 }
105}
106//=======================================================================
107//function : Compute
108//purpose :
109//=======================================================================
110
111void AIS_ConnectedInteractive::
112Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
113 const Handle(Prs3d_Presentation)& aPresentation,
114 const Standard_Integer aMode)
115{
116 static Handle(Geom_Transformation) myPrsTrans ;
117
118 if(!(HasLocation() ||HasConnection())) return;
119
120 if(HasConnection()){
121 aPresentation->Clear(Standard_False);
122 aPresentation->RemoveAll();
123 aPresentationManager->Connect( this,myReference, aMode, aMode);
124 if(aPresentationManager->Presentation(myReference,aMode)->MustBeUpdated())
125 aPresentationManager->Update(myReference,aMode);
126
127 }
128 if(HasLocation()){
129 myPrsTrans = new Geom_Transformation(myLocation.Transformation());
130 aPresentationManager->Transform(this, myPrsTrans, aMode); }
131 aPresentation->ReCompute();
132}
133
134void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
135{
136// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
137 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
138}
139
140void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation)
141{
142// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
143 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
144}
145
146void AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, const Handle_Graphic2d_GraphicObject& aGraphicObject, const int anInteger)
147{
148// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
149 PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
150}
151
152//=======================================================================
153//function : ComputeSelection
154//purpose :
155//=======================================================================
ac04d101
SA
156
157void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
158 const Standard_Integer aMode)
7fd59977 159{
160 if(!(HasLocation() ||HasConnection())) return;
161
162 aSel->Clear();
163 if(!myReference->HasSelection(aMode))
164 myReference->UpdateSelection(aMode);
ac04d101 165
7fd59977 166 const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);
167 Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);
ac04d101 168 Handle(Select3D_SensitiveEntity) SE3D, SNew;
7fd59977 169
170 if(TheRefSel->IsEmpty())
171 myReference->UpdateSelection(aMode);
ac04d101
SA
172 for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next())
173 {
174 SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive());
175 if(!SE3D.IsNull())
176 {
177 // Get the copy of SE3D
7fd59977 178 SNew = SE3D->GetConnected(myLocation);
179 if(aMode==0)
ac04d101
SA
180 {
181 SNew->Set(OWN);
182 // In case if SE3D caches some location-dependent data
183 // that must be updated after setting OWN
184 SNew->SetLocation(myLocation);
185 }
7fd59977 186 aSel->Add(SNew);
187 }
188 }
7fd59977 189}
190
191void AIS_ConnectedInteractive::UpdateLocation()
192{
193// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()");
194 SelectMgr_SelectableObject::UpdateLocation() ;
195}
196void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
197{
198// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)");
199 SelectMgr_SelectableObject::UpdateLocation(Sel) ;
200}
201/*void AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation& aPresentation)
202{
203// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation&)");
204 SelectMgr_SelectableObject::UpdateLocation(aPresentation) ;
205}*/