0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / TPrsStd / TPrsStd_PointDriver.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <AIS_InteractiveContext.hxx>
16 #include <AIS_InteractiveObject.hxx>
17 #include <AIS_Point.hxx>
18 #include <Geom_CartesianPoint.hxx>
19 #include <Geom_Point.hxx>
20 #include <gp_Pnt.hxx>
21 #include <Standard_Type.hxx>
22 #include <TDataXtd_Geometry.hxx>
23 #include <TDataXtd_Point.hxx>
24 #include <TDF_Label.hxx>
25 #include <TPrsStd_PointDriver.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_PointDriver,TPrsStd_Driver)
28
29 //#include <TDataStd_Datum.hxx>
30 //=======================================================================
31 //function :
32 //purpose  : 
33 //=======================================================================
34 TPrsStd_PointDriver::TPrsStd_PointDriver()
35 {
36 }
37
38 //=======================================================================
39 //function :
40 //purpose  : 
41 //=======================================================================
42 Standard_Boolean TPrsStd_PointDriver::Update (const TDF_Label& aLabel,
43                                              Handle(AIS_InteractiveObject)& anAISObject) 
44 {
45   Handle(TDataXtd_Point) appoint;
46
47   if ( !aLabel.FindAttribute(TDataXtd_Point::GetID(), appoint) ) {
48     return Standard_False;
49   }
50  
51   gp_Pnt pnt;
52   if (!TDataXtd_Geometry::Point(aLabel,pnt)) {
53     return Standard_False;
54   }
55   Handle(Geom_CartesianPoint) apt = new Geom_CartesianPoint(pnt);
56   
57   //  Update de l'AIS
58   Handle(AIS_Point) aistrihed;
59   if (anAISObject.IsNull())
60     aistrihed = new AIS_Point(apt);
61   else {
62     aistrihed = Handle(AIS_Point)::DownCast(anAISObject);
63     if (aistrihed.IsNull()) 
64       aistrihed = new AIS_Point(apt);
65     else {
66       aistrihed->SetComponent(apt);
67       aistrihed->ResetTransformation();
68       aistrihed->SetToUpdate();
69       aistrihed->UpdateSelection();
70     }
71   }
72   anAISObject = aistrihed;
73   return Standard_True;
74 }
75