1 // Created on: 1999-09-30
2 // Created by: Sergey RUIN
3 // Copyright (c) 1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TPrsStd_GeometryDriver.ixx>
18 #include <TDataXtd.hxx>
19 #include <TDF_Label.hxx>
20 #include <TNaming_NamedShape.hxx>
21 #include <TNaming_Tool.hxx>
22 #include <TDataXtd_Geometry.hxx>
23 #include <Geom_CartesianPoint.hxx>
24 #include <Geom_Line.hxx>
25 #include <Geom_Circle.hxx>
26 #include <AIS_Line.hxx>
27 #include <AIS_Point.hxx>
28 #include <AIS_Circle.hxx>
29 #include <AIS_Shape.hxx>
30 #include <AIS_Drawer.hxx>
31 #include <AIS_InteractiveContext.hxx>
34 #include <gp_Circ.hxx>
35 #include <gp_Elips.hxx>
36 #include <BRepBuilderAPI_MakeEdge.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Edge.hxx>
41 //=======================================================================
44 //=======================================================================
45 TPrsStd_GeometryDriver::TPrsStd_GeometryDriver()
50 //=======================================================================
53 //=======================================================================
54 Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
55 Handle(AIS_InteractiveObject)& anAISObject)
57 Handle(TDataXtd_Geometry) aGeom;
58 Handle(TNaming_NamedShape) NS;
59 TDataXtd_GeometryEnum GeomType;
61 if (!aLabel.FindAttribute(TDataXtd_Geometry::GetID(), aGeom)) {
62 if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
63 GeomType = TDataXtd_Geometry::Type(aLabel);
66 return Standard_False;
70 GeomType = aGeom->GetType();
77 if (!TDataXtd_Geometry::Point(aLabel,pt)) return Standard_False;
78 Handle(Geom_Point) apt = new Geom_CartesianPoint(pt);
79 Handle(AIS_Point) ais1;
80 if( anAISObject.IsNull() ) ais1 = new AIS_Point(apt);
82 ais1 = Handle(AIS_Point)::DownCast(anAISObject);
84 ais1 = new AIS_Point(apt);
86 ais1->SetComponent(apt);
87 ais1->ResetTransformation();
89 ais1->UpdateSelection();
94 anAISObject->SetColor(Quantity_NOC_RED);
100 if (!TDataXtd_Geometry::Line(aLabel,ln)) return Standard_False;
101 Handle(Geom_Line) aln = new Geom_Line(ln);
102 Handle(AIS_Line) ais2;
103 if( anAISObject.IsNull() ) ais2 = new AIS_Line(aln);
105 ais2 = Handle(AIS_Line)::DownCast(anAISObject);
107 ais2 = new AIS_Line(aln);
110 ais2->ResetTransformation();
112 ais2->UpdateSelection();
116 anAISObject->SetColor(Quantity_NOC_RED);
117 anAISObject->SetInfiniteState(Standard_True);
120 case TDataXtd_CIRCLE :
122 Handle(AIS_Line) ais2;
124 if (!TDataXtd_Geometry::Circle(aLabel,cir)) return Standard_False;
125 Handle(Geom_Circle) acir = new Geom_Circle(cir);
126 Handle(AIS_Circle) ais3;
127 if (anAISObject.IsNull()) ais3 = new AIS_Circle(acir);
129 ais3 = Handle(AIS_Circle)::DownCast(anAISObject);
131 ais3 = new AIS_Circle(acir);
133 ais3->SetCircle(acir);
134 ais3->ResetTransformation();
136 ais3->UpdateSelection();
140 anAISObject->SetColor(Quantity_NOC_RED);
143 case TDataXtd_ELLIPSE :
146 if (!TDataXtd_Geometry::Ellipse(aLabel, elp)) return Standard_False;
147 BRepBuilderAPI_MakeEdge mkEdge(elp);
148 if( !mkEdge.IsDone() ) return Standard_False;
149 Handle(AIS_Shape) ais;
150 if (anAISObject.IsNull()) ais = new AIS_Shape(mkEdge);
152 ais = Handle(AIS_Shape)::DownCast(anAISObject);
154 ais = new AIS_Shape(mkEdge);
156 ais->ResetTransformation();
159 ais->UpdateSelection();
163 anAISObject->SetColor(Quantity_NOC_RED);
167 return Standard_False;
170 return Standard_True;