0026937: Eliminate NO_CXX_EXCEPTION macro support
[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{
f838dac4 51 myHilightDrawer = new Prs3d_Drawer();
52 myHilightDrawer->SetDisplayMode (-99);
53 myHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_GRAY80, 3.0));
54 myHilightDrawer->SetColor (Quantity_NOC_GRAY80);
55 myDynHilightDrawer = new Prs3d_Drawer();
56 myDynHilightDrawer->SetDisplayMode (-99);
57 myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
58 myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
7fd59977 59}
60
61//=======================================================================
62//function : Component
63//purpose :
64//=======================================================================
65
66Handle(Geom_Point) AIS_Point::Component()
67{
68 return myComponent;
69}
70
71//=======================================================================
72//function : SetComponent
73//purpose :
74//=======================================================================
75
76 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
77{
78 myComponent = aComponent;
79}
80
81//=======================================================================
82//function : Compute
83//purpose :
84//=======================================================================
85void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
86 const Handle(Prs3d_Presentation)& aPresentation,
87 const Standard_Integer aMode)
88{
7fd59977 89 aPresentation->SetInfiniteState(myInfiniteState);
90
91 if (aMode==0)
92 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
93 else if (aMode== -99)
94 {
7fd59977 95 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
f838dac4 96 TheGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect());
a577aaab 97 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
98 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
99 TheGroup->AddPrimitiveArray (aPoint);
7fd59977 100 }
101
102}
103
104//=======================================================================
105//function : Compute
106//purpose :
107//=======================================================================
108
857ffd5e 109void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
110 const Handle(Geom_Transformation)& aTransformation,
111 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 112{
9775fa61 113// throw Standard_NotImplemented("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
7fd59977 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)
7fd59977 137{
138 SetColor(Quantity_Color(aCol));
139}
140
f838dac4 141void AIS_Point::SetColor (const Quantity_Color& theCol)
7fd59977 142{
143 hasOwnColor=Standard_True;
f838dac4 144 myDrawer->SetColor (theCol);
7fd59977 145 UpdatePointValues();
146}
147
148//=======================================================================
149//function : UnsetColor
150//purpose :
151//=======================================================================
152void AIS_Point::UnsetColor()
153{
154 hasOwnColor=Standard_False;
155 UpdatePointValues();
156}
157
158
159//=======================================================================
160//function : Vertex
161//purpose :
162//=======================================================================
163TopoDS_Vertex AIS_Point::Vertex() const
164{
165 gp_Pnt P = myComponent->Pnt();
166 return BRepBuilderAPI_MakeVertex(P);
167}
168
128cc8df 169
7fd59977 170//=======================================================================
171//function : Compute
172//purpose : to avoid warning
173//=======================================================================
174void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
175 const Handle(Prs3d_Presentation)&)
176{
177}
178
179//=======================================================================
180//function : SetMarker
181//purpose :
182//=======================================================================
183
184void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
185{
186 myTOM = aTOM;
187 myHasTOM = Standard_True;
188 UpdatePointValues();
189}
190
191//=======================================================================
192//function : UnsetMarker
193//purpose :
194//=======================================================================
195void AIS_Point::UnsetMarker()
196{
197 myHasTOM = Standard_False;
198 UpdatePointValues();
199}
200
201//=======================================================================
202//function : AcceptDisplayMode
203//purpose :
204//=======================================================================
205
f838dac4 206 Standard_Boolean AIS_Point::AcceptDisplayMode (const Standard_Integer theMode) const
207{
208 return theMode == 0
209 || theMode == -99;
210}
7fd59977 211
212//=======================================================================
213//function : UpdatePointValues
214//purpose :
215//=======================================================================
216
217void AIS_Point::UpdatePointValues()
218{
219
6262338c 220 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
221 {
222 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
7fd59977 223 return;
224 }
b6472664 225 Quantity_Color aCol (Quantity_NOC_YELLOW);
226 Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
227 Standard_Real aScale = 1.0;
228 if (myDrawer->HasLink())
229 {
230 aCol = myDrawer->Link()->PointAspect()->Aspect()->Color();
231 aTOM = myDrawer->Link()->PointAspect()->Aspect()->Type();
232 aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
7fd59977 233 }
b6472664 234
f838dac4 235 if(hasOwnColor) aCol = myDrawer->Color();
7fd59977 236 if(myOwnWidth!=0.0) aScale = myOwnWidth;
237 if(myHasTOM) aTOM = myTOM;
238
239
6262338c 240 if(myDrawer->HasOwnPointAspect()){
7fd59977 241 // CLE
242 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
243 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
244 // ENDCLE
245 PA->SetColor(aCol);
246 PA->SetTypeOfMarker(aTOM);
247 PA->SetScale(aScale);
248 }
249 else
250 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
251}
252