0023663: Removing 2D viewer library
[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
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#define GER61351 //GG_171199 Enable to set an object RGB color
23// instead a restricted object NameOfColor.
24
25#include <AIS_Point.ixx>
26#include <Aspect_TypeOfLine.hxx>
27#include <Prs3d_Drawer.hxx>
28#include <Prs3d_PointAspect.hxx>
29#include <Graphic3d_Structure.hxx>
30#include <Graphic3d_Group.hxx>
31#include <Quantity_Color.hxx>
32#include <Graphic3d_Vertex.hxx>
33#include <Graphic3d_AspectMarker3d.hxx>
34#include <SelectMgr_EntityOwner.hxx>
35#include <SelectBasics_EntityOwner.hxx>
36#include <Select3D_SensitivePoint.hxx>
37#include <StdPrs_Point.hxx>
38#include <Geom_Point.hxx>
39#include <BRepBuilderAPI_MakeVertex.hxx>
40#include <AIS_Drawer.hxx>
41
42#include <AIS_InteractiveContext.hxx>
43//=======================================================================
44//function : AIS_Point
45//purpose :
46//=======================================================================
47AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
48myComponent(aComponent),
49myHasTOM(Standard_False),
50myTOM(Aspect_TOM_PLUS)
51{
52 myHilightMode=-99;
53}
54
55//=======================================================================
56//function : Component
57//purpose :
58//=======================================================================
59
60Handle(Geom_Point) AIS_Point::Component()
61{
62 return myComponent;
63}
64
65//=======================================================================
66//function : SetComponent
67//purpose :
68//=======================================================================
69
70 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
71{
72 myComponent = aComponent;
73}
74
75//=======================================================================
76//function : Compute
77//purpose :
78//=======================================================================
79void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
80 const Handle(Prs3d_Presentation)& aPresentation,
81 const Standard_Integer aMode)
82{
83 aPresentation->Clear();
84
85 aPresentation->SetInfiniteState(myInfiniteState);
86
87 if (aMode==0)
88 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
89 else if (aMode== -99)
90 {
91 // Beeurk.. a revoir - rob-25/04/97
92 static Handle(Graphic3d_AspectMarker3d) PtA =
93 new Graphic3d_AspectMarker3d ();
94 PtA->SetType(Aspect_TOM_PLUS);
95 PtA->SetScale(3.);
96 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
97 TheGroup->SetPrimitivesAspect(PtA);
98 Graphic3d_Vertex Vtx(myComponent->X(),myComponent->Y(),myComponent->Z());
99 TheGroup->Marker(Vtx);
100 }
101
102}
103
104//=======================================================================
105//function : Compute
106//purpose :
107//=======================================================================
108
109void AIS_Point::Compute(const Handle_Prs3d_Projector& aProjector,
110 const Handle_Geom_Transformation& aTransformation,
111 const Handle_Prs3d_Presentation& aPresentation)
112{
113// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
114 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
115}
116
117//=======================================================================
118//function : ComputeSelection
119//purpose :
120//=======================================================================
121void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
122 const Standard_Integer /*aMode*/)
123{
124 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
125// eown -> SelectBasics_EntityOwner::Set(5);
126 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
127 myComponent->Pnt());
128 aSelection->Add(sp);
129}
130
131//=======================================================================
132//function : SetColor
133//purpose :
134//=======================================================================
135
136void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
137#ifdef GER61351
138{
139 SetColor(Quantity_Color(aCol));
140}
141
142void AIS_Point::SetColor(const Quantity_Color &aCol)
143#endif
144{
145 hasOwnColor=Standard_True;
146 myOwnColor=aCol;
147 UpdatePointValues();
148}
149
150//=======================================================================
151//function : UnsetColor
152//purpose :
153//=======================================================================
154void AIS_Point::UnsetColor()
155{
156 hasOwnColor=Standard_False;
157 UpdatePointValues();
158}
159
160
161//=======================================================================
162//function : Vertex
163//purpose :
164//=======================================================================
165TopoDS_Vertex AIS_Point::Vertex() const
166{
167 gp_Pnt P = myComponent->Pnt();
168 return BRepBuilderAPI_MakeVertex(P);
169}
170
128cc8df 171
7fd59977 172//=======================================================================
173//function : Compute
174//purpose : to avoid warning
175//=======================================================================
176void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
177 const Handle(Prs3d_Presentation)&)
178{
179}
180
181//=======================================================================
182//function : SetMarker
183//purpose :
184//=======================================================================
185
186void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
187{
188 myTOM = aTOM;
189 myHasTOM = Standard_True;
190 UpdatePointValues();
191}
192
193//=======================================================================
194//function : UnsetMarker
195//purpose :
196//=======================================================================
197void AIS_Point::UnsetMarker()
198{
199 myHasTOM = Standard_False;
200 UpdatePointValues();
201}
202
203//=======================================================================
204//function : AcceptDisplayMode
205//purpose :
206//=======================================================================
207
208 Standard_Boolean AIS_Point::
209AcceptDisplayMode(const Standard_Integer aMode) const
210{return aMode == 0;}
211
212
213//=======================================================================
214//function : UpdatePointValues
215//purpose :
216//=======================================================================
217
218void AIS_Point::UpdatePointValues()
219{
220
221 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM){
222 myDrawer->PointAspect().Nullify();
223 return;
224 }
225#ifdef GER61351
226 Quantity_Color aCol;
227#else
228 Quantity_NameOfColor aCol;
229#endif
230 Quantity_Color QCO;
231 Aspect_TypeOfMarker aTOM;
232 Standard_Real aScale;
233
234 if(myDrawer->HasLink()){
235 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
236 aCol = QCO.Name();
237 }
238 else{
239 aCol = Quantity_NOC_YELLOW;
240 aTOM = Aspect_TOM_PLUS;
241 aScale = 1;
242 }
243 if(hasOwnColor) aCol = myOwnColor;
244 if(myOwnWidth!=0.0) aScale = myOwnWidth;
245 if(myHasTOM) aTOM = myTOM;
246
247
248 if(myDrawer->HasPointAspect()){
249 // CLE
250 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
251 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
252 // ENDCLE
253 PA->SetColor(aCol);
254 PA->SetTypeOfMarker(aTOM);
255 PA->SetScale(aScale);
256 }
257 else
258 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
259}
260