Commit | Line | Data |
---|---|---|
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 | //======================================================================= | |
39 | AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): | |
40 | AIS_InteractiveObject(aTypeOfPresentation3d) | |
41 | { | |
42 | SetHilightMode(0); | |
43 | } | |
44 | ||
45 | //======================================================================= | |
46 | //function : Type | |
47 | //purpose : | |
48 | //======================================================================= | |
49 | AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const | |
50 | {return AIS_KOI_Object;} | |
51 | ||
52 | Standard_Integer AIS_ConnectedInteractive::Signature() const | |
53 | {return 0; } | |
54 | ||
55 | ||
56 | ||
57 | ||
58 | //======================================================================= | |
59 | //function : Connect | |
60 | //purpose : | |
61 | //======================================================================= | |
62 | void AIS_ConnectedInteractive:: | |
63 | Connect(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 | //======================================================================= | |
77 | void AIS_ConnectedInteractive:: | |
78 | Connect(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 | ||
96 | void 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 | |
792c785c | 108 | //purpose : |
7fd59977 | 109 | //======================================================================= |
792c785c | 110 | void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, |
111 | const Handle(Prs3d_Presentation)& thePrs, | |
112 | const Standard_Integer theMode) | |
7fd59977 | 113 | { |
792c785c | 114 | if (!(HasLocation() || HasConnection())) |
115 | { | |
116 | return; | |
117 | } | |
7fd59977 | 118 | |
792c785c | 119 | if (HasConnection()) |
120 | { | |
121 | thePrs->Clear (Standard_False); | |
122 | thePrs->RemoveAll(); | |
123 | ||
124 | if (!myReference->HasInteractiveContext()) | |
125 | { | |
126 | myReference->SetContext (GetContext()); | |
127 | } | |
128 | thePrsMgr->Connect (this, myReference, theMode, theMode); | |
129 | if (thePrsMgr->Presentation (myReference, theMode)->MustBeUpdated()) | |
130 | { | |
131 | thePrsMgr->Update (myReference, theMode); | |
132 | } | |
133 | } | |
134 | ||
135 | if (HasLocation()) | |
136 | { | |
137 | Handle(Geom_Transformation) aPrsTrans = new Geom_Transformation (myLocation.Transformation()); | |
138 | thePrsMgr->Transform (this, aPrsTrans, theMode); | |
7fd59977 | 139 | } |
792c785c | 140 | thePrs->ReCompute(); |
7fd59977 | 141 | } |
142 | ||
143 | void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) | |
144 | { | |
145 | // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); | |
146 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; | |
147 | } | |
148 | ||
149 | void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation) | |
150 | { | |
151 | // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)"); | |
152 | PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; | |
153 | } | |
154 | ||
7fd59977 | 155 | //======================================================================= |
156 | //function : ComputeSelection | |
157 | //purpose : | |
158 | //======================================================================= | |
ac04d101 SA |
159 | |
160 | void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, | |
161 | const Standard_Integer aMode) | |
7fd59977 | 162 | { |
163 | if(!(HasLocation() ||HasConnection())) return; | |
164 | ||
165 | aSel->Clear(); | |
166 | if(!myReference->HasSelection(aMode)) | |
167 | myReference->UpdateSelection(aMode); | |
ac04d101 | 168 | |
7fd59977 | 169 | const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode); |
170 | Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this); | |
ac04d101 | 171 | Handle(Select3D_SensitiveEntity) SE3D, SNew; |
7fd59977 | 172 | |
173 | if(TheRefSel->IsEmpty()) | |
174 | myReference->UpdateSelection(aMode); | |
ac04d101 SA |
175 | for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()) |
176 | { | |
177 | SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive()); | |
178 | if(!SE3D.IsNull()) | |
179 | { | |
180 | // Get the copy of SE3D | |
7fd59977 | 181 | SNew = SE3D->GetConnected(myLocation); |
182 | if(aMode==0) | |
ac04d101 SA |
183 | { |
184 | SNew->Set(OWN); | |
185 | // In case if SE3D caches some location-dependent data | |
186 | // that must be updated after setting OWN | |
187 | SNew->SetLocation(myLocation); | |
188 | } | |
7fd59977 | 189 | aSel->Add(SNew); |
190 | } | |
191 | } | |
7fd59977 | 192 | } |
193 | ||
194 | void AIS_ConnectedInteractive::UpdateLocation() | |
195 | { | |
196 | // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()"); | |
197 | SelectMgr_SelectableObject::UpdateLocation() ; | |
198 | } | |
199 | void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel) | |
200 | { | |
201 | // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)"); | |
202 | SelectMgr_SelectableObject::UpdateLocation(Sel) ; | |
203 | } | |
204 | /*void AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation& aPresentation) | |
205 | { | |
206 | // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation&)"); | |
207 | SelectMgr_SelectableObject::UpdateLocation(aPresentation) ; | |
208 | }*/ |