0030554: Coding - ChFiDS_CommonPoint uninitialized member traarc
[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
87432b82 17#include <AIS_Point.hxx>
42cf5bc1 18
19#include <AIS_InteractiveContext.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);
db60634e 55 myHilightDrawer->SetZLayer (Graphic3d_ZLayerId_UNKNOWN);
f838dac4 56 myDynHilightDrawer = new Prs3d_Drawer();
57 myDynHilightDrawer->SetDisplayMode (-99);
58 myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 3.0));
59 myDynHilightDrawer->SetColor (Quantity_NOC_CYAN1);
db60634e 60 myDynHilightDrawer->SetZLayer (Graphic3d_ZLayerId_Top);
7fd59977 61}
62
63//=======================================================================
64//function : Component
65//purpose :
66//=======================================================================
67
68Handle(Geom_Point) AIS_Point::Component()
69{
70 return myComponent;
71}
72
73//=======================================================================
74//function : SetComponent
75//purpose :
76//=======================================================================
77
78 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
79{
80 myComponent = aComponent;
81}
82
83//=======================================================================
84//function : Compute
85//purpose :
86//=======================================================================
87void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
88 const Handle(Prs3d_Presentation)& aPresentation,
89 const Standard_Integer aMode)
90{
7fd59977 91 aPresentation->SetInfiniteState(myInfiniteState);
92
93 if (aMode==0)
94 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
95 else if (aMode== -99)
96 {
7fd59977 97 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
f838dac4 98 TheGroup->SetPrimitivesAspect (myHilightDrawer->PointAspect()->Aspect());
a577aaab 99 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
100 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
101 TheGroup->AddPrimitiveArray (aPoint);
7fd59977 102 }
103
104}
105
106//=======================================================================
107//function : Compute
108//purpose :
109//=======================================================================
110
857ffd5e 111void AIS_Point::Compute(const Handle(Prs3d_Projector)& aProjector,
112 const Handle(Geom_Transformation)& aTransformation,
113 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 114{
9775fa61 115// throw Standard_NotImplemented("AIS_Point::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
7fd59977 116 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
117}
118
119//=======================================================================
120//function : ComputeSelection
121//purpose :
122//=======================================================================
123void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
124 const Standard_Integer /*aMode*/)
125{
126 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
127// eown -> SelectBasics_EntityOwner::Set(5);
128 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
129 myComponent->Pnt());
130 aSelection->Add(sp);
131}
132
133//=======================================================================
134//function : SetColor
87432b82 135//purpose :
7fd59977 136//=======================================================================
f838dac4 137void AIS_Point::SetColor (const Quantity_Color& theCol)
7fd59977 138{
139 hasOwnColor=Standard_True;
f838dac4 140 myDrawer->SetColor (theCol);
7fd59977 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
f838dac4 202 Standard_Boolean AIS_Point::AcceptDisplayMode (const Standard_Integer theMode) const
203{
204 return theMode == 0
205 || theMode == -99;
206}
7fd59977 207
208//=======================================================================
209//function : UpdatePointValues
210//purpose :
211//=======================================================================
212
213void AIS_Point::UpdatePointValues()
214{
215
6262338c 216 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM)
217 {
218 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
7fd59977 219 return;
220 }
b6472664 221 Quantity_Color aCol (Quantity_NOC_YELLOW);
222 Aspect_TypeOfMarker aTOM = Aspect_TOM_PLUS;
223 Standard_Real aScale = 1.0;
224 if (myDrawer->HasLink())
225 {
226 aCol = myDrawer->Link()->PointAspect()->Aspect()->Color();
227 aTOM = myDrawer->Link()->PointAspect()->Aspect()->Type();
228 aScale = myDrawer->Link()->PointAspect()->Aspect()->Scale();
7fd59977 229 }
b6472664 230
f838dac4 231 if(hasOwnColor) aCol = myDrawer->Color();
7fd59977 232 if(myOwnWidth!=0.0) aScale = myOwnWidth;
233 if(myHasTOM) aTOM = myTOM;
234
235
6262338c 236 if(myDrawer->HasOwnPointAspect()){
7fd59977 237 // CLE
238 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
239 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
240 // ENDCLE
241 PA->SetColor(aCol);
242 PA->SetTypeOfMarker(aTOM);
243 PA->SetScale(aScale);
244 }
245 else
246 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
247}
248