0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[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>
a577aaab 32#include <Graphic3d_ArrayOfPoints.hxx>
7fd59977 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);
a577aaab 98 Handle(Graphic3d_ArrayOfPoints) aPoint = new Graphic3d_ArrayOfPoints (1);
99 aPoint->AddVertex (myComponent->X(),myComponent->Y(),myComponent->Z());
100 TheGroup->AddPrimitiveArray (aPoint);
7fd59977 101 }
102
103}
104
105//=======================================================================
106//function : Compute
107//purpose :
108//=======================================================================
109
110void AIS_Point::Compute(const Handle_Prs3d_Projector& aProjector,
111 const Handle_Geom_Transformation& aTransformation,
112 const Handle_Prs3d_Presentation& aPresentation)
113{
114// Standard_NotImplemented::Raise("AIS_Point::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
115 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
116}
117
118//=======================================================================
119//function : ComputeSelection
120//purpose :
121//=======================================================================
122void AIS_Point::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
123 const Standard_Integer /*aMode*/)
124{
125 Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10);
126// eown -> SelectBasics_EntityOwner::Set(5);
127 Handle(Select3D_SensitivePoint) sp = new Select3D_SensitivePoint(eown,
128 myComponent->Pnt());
129 aSelection->Add(sp);
130}
131
132//=======================================================================
133//function : SetColor
134//purpose :
135//=======================================================================
136
137void AIS_Point::SetColor(const Quantity_NameOfColor aCol)
138#ifdef GER61351
139{
140 SetColor(Quantity_Color(aCol));
141}
142
143void AIS_Point::SetColor(const Quantity_Color &aCol)
144#endif
145{
146 hasOwnColor=Standard_True;
147 myOwnColor=aCol;
148 UpdatePointValues();
149}
150
151//=======================================================================
152//function : UnsetColor
153//purpose :
154//=======================================================================
155void AIS_Point::UnsetColor()
156{
157 hasOwnColor=Standard_False;
158 UpdatePointValues();
159}
160
161
162//=======================================================================
163//function : Vertex
164//purpose :
165//=======================================================================
166TopoDS_Vertex AIS_Point::Vertex() const
167{
168 gp_Pnt P = myComponent->Pnt();
169 return BRepBuilderAPI_MakeVertex(P);
170}
171
128cc8df 172
7fd59977 173//=======================================================================
174//function : Compute
175//purpose : to avoid warning
176//=======================================================================
177void AIS_Point::Compute(const Handle(Prs3d_Projector)&,
178 const Handle(Prs3d_Presentation)&)
179{
180}
181
182//=======================================================================
183//function : SetMarker
184//purpose :
185//=======================================================================
186
187void AIS_Point::SetMarker(const Aspect_TypeOfMarker aTOM)
188{
189 myTOM = aTOM;
190 myHasTOM = Standard_True;
191 UpdatePointValues();
192}
193
194//=======================================================================
195//function : UnsetMarker
196//purpose :
197//=======================================================================
198void AIS_Point::UnsetMarker()
199{
200 myHasTOM = Standard_False;
201 UpdatePointValues();
202}
203
204//=======================================================================
205//function : AcceptDisplayMode
206//purpose :
207//=======================================================================
208
209 Standard_Boolean AIS_Point::
210AcceptDisplayMode(const Standard_Integer aMode) const
211{return aMode == 0;}
212
213
214//=======================================================================
215//function : UpdatePointValues
216//purpose :
217//=======================================================================
218
219void AIS_Point::UpdatePointValues()
220{
221
222 if(!hasOwnColor && myOwnWidth==0.0 && !myHasTOM){
223 myDrawer->PointAspect().Nullify();
224 return;
225 }
226#ifdef GER61351
227 Quantity_Color aCol;
228#else
229 Quantity_NameOfColor aCol;
230#endif
231 Quantity_Color QCO;
232 Aspect_TypeOfMarker aTOM;
233 Standard_Real aScale;
234
235 if(myDrawer->HasLink()){
236 myDrawer->Link()->PointAspect()->Aspect()->Values(QCO,aTOM,aScale);
237 aCol = QCO.Name();
238 }
239 else{
240 aCol = Quantity_NOC_YELLOW;
241 aTOM = Aspect_TOM_PLUS;
242 aScale = 1;
243 }
244 if(hasOwnColor) aCol = myOwnColor;
245 if(myOwnWidth!=0.0) aScale = myOwnWidth;
246 if(myHasTOM) aTOM = myTOM;
247
248
249 if(myDrawer->HasPointAspect()){
250 // CLE
251 // const Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
252 Handle(Prs3d_PointAspect) PA = myDrawer->PointAspect();
253 // ENDCLE
254 PA->SetColor(aCol);
255 PA->SetTypeOfMarker(aTOM);
256 PA->SetScale(aScale);
257 }
258 else
259 myDrawer->SetPointAspect(new Prs3d_PointAspect(aTOM,aCol,aScale));
260}
261