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.
18 #include <AIS_Circle.hxx>
19 #include <AIS_InteractiveContext.hxx>
20 #include <AIS_InteractiveObject.hxx>
21 #include <AIS_Line.hxx>
22 #include <AIS_Point.hxx>
23 #include <AIS_Shape.hxx>
24 #include <BRepBuilderAPI_MakeEdge.hxx>
25 #include <Geom_CartesianPoint.hxx>
26 #include <Geom_Circle.hxx>
27 #include <Geom_Line.hxx>
28 #include <gp_Circ.hxx>
29 #include <gp_Elips.hxx>
32 #include <Standard_Type.hxx>
33 #include <TDataXtd.hxx>
34 #include <TDataXtd_Geometry.hxx>
35 #include <TDF_Label.hxx>
36 #include <TNaming_NamedShape.hxx>
37 #include <TNaming_Tool.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Shape.hxx>
40 #include <TPrsStd_GeometryDriver.hxx>
42 IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_GeometryDriver,TPrsStd_Driver)
44 //=======================================================================
47 //=======================================================================
48 TPrsStd_GeometryDriver::TPrsStd_GeometryDriver()
53 //=======================================================================
56 //=======================================================================
57 Standard_Boolean TPrsStd_GeometryDriver::Update(const TDF_Label& aLabel,
58 Handle(AIS_InteractiveObject)& anAISObject)
60 Handle(TDataXtd_Geometry) aGeom;
61 Handle(TNaming_NamedShape) NS;
62 TDataXtd_GeometryEnum GeomType;
64 if (!aLabel.FindAttribute(TDataXtd_Geometry::GetID(), aGeom)) {
65 if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
66 GeomType = TDataXtd_Geometry::Type(aLabel);
69 return Standard_False;
73 GeomType = aGeom->GetType();
80 if (!TDataXtd_Geometry::Point(aLabel,pt)) return Standard_False;
81 Handle(Geom_Point) apt = new Geom_CartesianPoint(pt);
82 Handle(AIS_Point) ais1;
83 if( anAISObject.IsNull() ) ais1 = new AIS_Point(apt);
85 ais1 = Handle(AIS_Point)::DownCast(anAISObject);
87 ais1 = new AIS_Point(apt);
89 ais1->SetComponent(apt);
90 ais1->ResetTransformation();
92 ais1->UpdateSelection();
97 anAISObject->SetColor(Quantity_NOC_RED);
103 if (!TDataXtd_Geometry::Line(aLabel,ln)) return Standard_False;
104 Handle(Geom_Line) aln = new Geom_Line(ln);
105 Handle(AIS_Line) ais2;
106 if( anAISObject.IsNull() ) ais2 = new AIS_Line(aln);
108 ais2 = Handle(AIS_Line)::DownCast(anAISObject);
110 ais2 = new AIS_Line(aln);
113 ais2->ResetTransformation();
115 ais2->UpdateSelection();
119 anAISObject->SetColor(Quantity_NOC_RED);
120 anAISObject->SetInfiniteState(Standard_True);
123 case TDataXtd_CIRCLE :
125 Handle(AIS_Line) ais2;
127 if (!TDataXtd_Geometry::Circle(aLabel,cir)) return Standard_False;
128 Handle(Geom_Circle) acir = new Geom_Circle(cir);
129 Handle(AIS_Circle) ais3;
130 if (anAISObject.IsNull()) ais3 = new AIS_Circle(acir);
132 ais3 = Handle(AIS_Circle)::DownCast(anAISObject);
134 ais3 = new AIS_Circle(acir);
136 ais3->SetCircle(acir);
137 ais3->ResetTransformation();
139 ais3->UpdateSelection();
143 anAISObject->SetColor(Quantity_NOC_RED);
146 case TDataXtd_ELLIPSE :
149 if (!TDataXtd_Geometry::Ellipse(aLabel, elp)) return Standard_False;
150 BRepBuilderAPI_MakeEdge mkEdge(elp);
151 if( !mkEdge.IsDone() ) return Standard_False;
152 Handle(AIS_Shape) ais;
153 if (anAISObject.IsNull()) ais = new AIS_Shape(mkEdge);
155 ais = Handle(AIS_Shape)::DownCast(anAISObject);
157 ais = new AIS_Shape(mkEdge);
159 ais->ResetTransformation();
162 ais->UpdateSelection();
166 anAISObject->SetColor(Quantity_NOC_RED);
170 return Standard_False;
173 return Standard_True;