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
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.
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.
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.
22 #define GER61351 //GG_171199 Enable to set an object RGB color
23 // instead a restricted object NameOfColor.
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>
42 #include <AIS_InteractiveContext.hxx>
43 //=======================================================================
44 //function : AIS_Point
46 //=======================================================================
47 AIS_Point::AIS_Point(const Handle(Geom_Point)& aComponent):
48 myComponent(aComponent),
49 myHasTOM(Standard_False),
50 myTOM(Aspect_TOM_PLUS)
55 //=======================================================================
56 //function : Component
58 //=======================================================================
60 Handle(Geom_Point) AIS_Point::Component()
65 //=======================================================================
66 //function : SetComponent
68 //=======================================================================
70 void AIS_Point::SetComponent(const Handle(Geom_Point)& aComponent)
72 myComponent = aComponent;
75 //=======================================================================
78 //=======================================================================
79 void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
80 const Handle(Prs3d_Presentation)& aPresentation,
81 const Standard_Integer aMode)
83 aPresentation->Clear();
85 aPresentation->SetInfiniteState(myInfiniteState);
88 StdPrs_Point::Add(aPresentation,myComponent,myDrawer);
91 // Beeurk.. a revoir - rob-25/04/97
92 static Handle(Graphic3d_AspectMarker3d) PtA =
93 new Graphic3d_AspectMarker3d ();
94 PtA->SetType(Aspect_TOM_PLUS);
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);
104 //=======================================================================
107 //=======================================================================
109 void AIS_Point::Compute(const Handle_Prs3d_Projector& aProjector,
110 const Handle_Geom_Transformation& aTransformation,
111 const Handle_Prs3d_Presentation& aPresentation)
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) ;
117 //=======================================================================
118 //function : ComputeSelection
120 //=======================================================================
121 void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
122 const Standard_Integer /*aMode*/)
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,
131 //=======================================================================
132 //function : SetColor
134 //=======================================================================
136 void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
139 SetColor(Quantity_Color(aCol));
142 void AIS_Point::SetColor(const Quantity_Color &aCol)
145 hasOwnColor=Standard_True;
150 //=======================================================================
151 //function : UnsetColor
153 //=======================================================================
154 void AIS_Point::UnsetColor()
156 hasOwnColor=Standard_False;
161 //=======================================================================
164 //=======================================================================
165 TopoDS_Vertex AIS_Point::Vertex() const
167 gp_Pnt P = myComponent->Pnt();
168 return BRepBuilderAPI_MakeVertex(P);
171 //=======================================================================
173 //purpose : to avoid warning
174 //=======================================================================
175 void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager2d)&,
176 const Handle(Graphic2d_GraphicObject)&,
177 const Standard_Integer)
180 //=======================================================================
182 //purpose : to avoid warning
183 //=======================================================================
184 void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
185 const Handle(Prs3d_Presentation)&)
189 //=======================================================================
190 //function : SetMarker
192 //=======================================================================
194 void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
197 myHasTOM = Standard_True;
201 //=======================================================================
202 //function : UnsetMarker
204 //=======================================================================
205 void AIS_Point::UnsetMarker()
207 myHasTOM = Standard_False;
211 //=======================================================================
212 //function : AcceptDisplayMode
214 //=======================================================================
216 Standard_Boolean AIS_Point::
217 AcceptDisplayMode(const Standard_Integer aMode) const
221 //=======================================================================
222 //function : UpdatePointValues
224 //=======================================================================
226 void AIS_Point::UpdatePointValues()
229 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM){
230 myDrawer->PointAspect().Nullify();
236 Quantity_NameOfColor aCol;
239 Aspect_TypeOfMarker aTOM;
240 Standard_Real aScale;
242 if(myDrawer->HasLink()){
243 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
247 aCol = Quantity_NOC_YELLOW;
248 aTOM = Aspect_TOM_PLUS;
251 if(hasOwnColor) aCol = myOwnColor;
252 if(myOwnWidth!=0.0) aScale = myOwnWidth;
253 if(myHasTOM) aTOM = myTOM;
256 if(myDrawer->HasPointAspect()){
258 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
259 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
262 PA->SetTypeOfMarker(aTOM);
263 PA->SetScale(aScale);
266 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));