0028162: Draw Harness - eliminate usage of deprecated Local Context
[occt.git] / src / AIS / AIS_Point.cxx
CommitLineData
b311480e 1// Created on: 1995-08-09
2// Created by: Arnaud BOUZY/Odile Olivier
3// Copyright (c) 1995-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
42cf5bc1 17
18#include <AIS_InteractiveContext.hxx>
19#include <AIS_Point.hxx>
7fd59977 20#include <Aspect_TypeOfLine.hxx>
42cf5bc1 21#include <BRepBuilderAPI_MakeVertex.hxx>
22#include <Geom_Point.hxx>
23#include <Geom_Transformation.hxx>
24#include <Graphic3d_ArrayOfPoints.hxx>
25#include <Graphic3d_AspectMarker3d.hxx>
26#include <Graphic3d_Group.hxx>
27#include <Graphic3d_Structure.hxx>
7fd59977 28#include <Prs3d_Drawer.hxx>
29#include <Prs3d_PointAspect.hxx>
42cf5bc1 30#include <Prs3d_Presentation.hxx>
31#include <Prs3d_Projector.hxx>
7fd59977 32#include <Quantity_Color.hxx>
7fd59977 33#include <Select3D_SensitivePoint.hxx>
42cf5bc1 34#include <SelectBasics_EntityOwner.hxx>
35#include <SelectMgr_EntityOwner.hxx>
36#include <Standard_Type.hxx>
7fd59977 37#include <StdPrs_Point.hxx>
42cf5bc1 38#include <TopoDS_Vertex.hxx>
7fd59977 39
92efcf78 40IMPLEMENT_STANDARD_RTTIEXT(AIS_Point,AIS_InteractiveObject)
41
7fd59977 42//=======================================================================
43//function : AIS_Point
44//purpose :
45//=======================================================================
46AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
47myComponent(aComponent),
48myHasTOM(Standard_False),
49myTOM(Aspect_TOM_PLUS)
50{
51 myHilightMode=-99;
52}
53
54//=======================================================================
55//function : Component
56//purpose :
57//=======================================================================
58
59Handle(Geom_Point) AIS_Point::Component()
60{
61 return myComponent;
62}
63
64//=======================================================================
65//function : SetComponent
66//purpose :
67//=======================================================================
68
69 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
70{
71 myComponent = aComponent;
72}
73
74//=======================================================================
75//function : Compute
76//purpose :
77//=======================================================================
78void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
79 const Handle(Prs3d_Presentation)& aPresentation,
80 const Standard_Integer aMode)
81{
7fd59977 82 aPresentation->SetInfiniteState(myInfiniteState);
83
84 if (aMode==0)
85 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
86 else if (aMode== -99)
87 {
016e5959 88 Handle(Graphic3d_AspectMarker3d) PtA = new Graphic3d_AspectMarker3d ();
7fd59977 89 PtA->SetType(Aspect_TOM_PLUS);
90 PtA->SetScale(3.);
91 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
92 TheGroup->SetPrimitivesAspect(PtA);
a577aaab 93 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
94 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
95 TheGroup->AddPrimitiveArray (aPoint);
7fd59977 96 }
97
98}
99
100//=======================================================================
101//function : Compute
102//purpose :
103//=======================================================================
104
857ffd5e 105void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
106 const Handle(Geom_Transformation)& aTransformation,
107 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 108{
857ffd5e 109// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
7fd59977 110 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
111}
112
113//=======================================================================
114//function : ComputeSelection
115//purpose :
116//=======================================================================
117void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
118 const Standard_Integer /*aMode*/)
119{
120 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
121// eown -> SelectBasics_EntityOwner::Set(5);
122 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
123 myComponent->Pnt());
124 aSelection->Add(sp);
125}
126
127//=======================================================================
128//function : SetColor
129//purpose :
130//=======================================================================
131
132void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
7fd59977 133{
134 SetColor(Quantity_Color(aCol));
135}
136
137void AIS_Point::SetColor(const Quantity_Color &aCol)
7fd59977 138{
139 hasOwnColor=Standard_True;
140 myOwnColor=aCol;
141 UpdatePointValues();
142}
143
144//=======================================================================
145//function : UnsetColor
146//purpose :
147//=======================================================================
148void AIS_Point::UnsetColor()
149{
150 hasOwnColor=Standard_False;
151 UpdatePointValues();
152}
153
154
155//=======================================================================
156//function : Vertex
157//purpose :
158//=======================================================================
159TopoDS_Vertex AIS_Point::Vertex() const
160{
161 gp_Pnt P = myComponent->Pnt();
162 return BRepBuilderAPI_MakeVertex(P);
163}
164
128cc8df 165
7fd59977 166//=======================================================================
167//function : Compute
168//purpose : to avoid warning
169//=======================================================================
170void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
171 const Handle(Prs3d_Presentation)&)
172{
173}
174
175//=======================================================================
176//function : SetMarker
177//purpose :
178//=======================================================================
179
180void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
181{
182 myTOM = aTOM;
183 myHasTOM = Standard_True;
184 UpdatePointValues();
185}
186
187//=======================================================================
188//function : UnsetMarker
189//purpose :
190//=======================================================================
191void AIS_Point::UnsetMarker()
192{
193 myHasTOM = Standard_False;
194 UpdatePointValues();
195}
196
197//=======================================================================
198//function : AcceptDisplayMode
199//purpose :
200//=======================================================================
201
202 Standard_Boolean AIS_Point::
203AcceptDisplayMode(const Standard_Integer aMode) const
204{return aMode == 0;}
205
206
207//=======================================================================
208//function : UpdatePointValues
209//purpose :
210//=======================================================================
211
212void AIS_Point::UpdatePointValues()
213{
214
6262338c 215 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
216 {
217 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
7fd59977 218 return;
219 }
b6472664 220 Quantity_Color aCol (Quantity_NOC_YELLOW);
221 Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
222 Standard_Real aScale = 1.0;
223 if (myDrawer->HasLink())
224 {
225 aCol = myDrawer->Link()->PointAspect()->Aspect()->Color();
226 aTOM = myDrawer->Link()->PointAspect()->Aspect()->Type();
227 aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
7fd59977 228 }
b6472664 229
7fd59977 230 if(hasOwnColor) aCol = myOwnColor;
231 if(myOwnWidth!=0.0) aScale = myOwnWidth;
232 if(myHasTOM) aTOM = myTOM;
233
234
6262338c 235 if(myDrawer->HasOwnPointAspect()){
7fd59977 236 // CLE
237 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
238 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
239 // ENDCLE
240 PA->SetColor(aCol);
241 PA->SetTypeOfMarker(aTOM);
242 PA->SetScale(aScale);
243 }
244 else
245 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
246}
247