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