1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <AIS_Axis.hxx>
16 #include <AIS_InteractiveContext.hxx>
17 #include <AIS_InteractiveObject.hxx>
18 #include <Geom_Line.hxx>
20 #include <Standard_Type.hxx>
21 #include <TDataXtd_Axis.hxx>
22 #include <TDataXtd_Geometry.hxx>
23 #include <TDF_Label.hxx>
24 #include <TNaming_NamedShape.hxx>
25 #include <TNaming_Tool.hxx>
26 #include <TopoDS_Shape.hxx>
27 #include <TPrsStd_AxisDriver.hxx>
29 IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_AxisDriver,TPrsStd_Driver)
31 //=======================================================================
34 //=======================================================================
35 TPrsStd_AxisDriver::TPrsStd_AxisDriver()
40 //=======================================================================
43 //=======================================================================
44 Standard_Boolean TPrsStd_AxisDriver::Update (const TDF_Label& aLabel,
45 Handle(AIS_InteractiveObject)& anAISObject)
48 Handle(TDataXtd_Axis) apAxis;
49 if ( !aLabel.FindAttribute(TDataXtd_Axis::GetID(), apAxis) ) {
50 return Standard_False;
54 Handle(TNaming_NamedShape) NS;
55 if(aLabel.FindAttribute(TNaming_NamedShape::GetID(),NS)){
56 if(TNaming_Tool::GetShape(NS).IsNull()){
57 return Standard_False;
61 Handle(AIS_Axis) aistrihed;
62 if (TDataXtd_Geometry::Line(aLabel,lin)) {
63 Handle(Geom_Line) apt = new Geom_Line (lin);
66 if (anAISObject.IsNull())
67 aistrihed = new AIS_Axis(apt);
69 aistrihed = Handle(AIS_Axis)::DownCast(anAISObject);
70 if (aistrihed.IsNull())
71 aistrihed = new AIS_Axis(apt);
73 aistrihed->SetComponent(apt);
74 aistrihed->ResetTransformation();
75 aistrihed->SetToUpdate();
76 aistrihed->UpdateSelection();
79 anAISObject = aistrihed;
82 return Standard_False;