0024837: Visualization - revise design and implementation of connected Interactive...
[occt.git] / src / TPrsStd / TPrsStd_PointDriver.cxx
... / ...
CommitLineData
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#include <TPrsStd_PointDriver.ixx>
15
16#include <TDF_Label.hxx>
17#include <TDataXtd_Point.hxx>
18#include <TDataXtd_Geometry.hxx>
19//#include <TDataStd_Datum.hxx>
20#include <AIS_Point.hxx>
21#include <AIS_Drawer.hxx>
22#include <AIS_InteractiveContext.hxx>
23#include <Geom_Point.hxx>
24#include <Geom_CartesianPoint.hxx>
25#include <gp_Pnt.hxx>
26
27
28
29//=======================================================================
30//function :
31//purpose :
32//=======================================================================
33TPrsStd_PointDriver::TPrsStd_PointDriver()
34{
35}
36
37//=======================================================================
38//function :
39//purpose :
40//=======================================================================
41Standard_Boolean TPrsStd_PointDriver::Update (const TDF_Label& aLabel,
42 Handle(AIS_InteractiveObject)& anAISObject)
43{
44 Handle(TDataXtd_Point) appoint;
45
46 if ( !aLabel.FindAttribute(TDataXtd_Point::GetID(), appoint) ) {
47 return Standard_False;
48 }
49
50 gp_Pnt pnt;
51 if (!TDataXtd_Geometry::Point(aLabel,pnt)) {
52 return Standard_False;
53 }
54 Handle(Geom_CartesianPoint) apt = new Geom_CartesianPoint(pnt);
55
56 // Update de l'AIS
57 Handle(AIS_Point) aistrihed;
58 if (anAISObject.IsNull())
59 aistrihed = new AIS_Point(apt);
60 else {
61 aistrihed = Handle(AIS_Point)::DownCast(anAISObject);
62 if (aistrihed.IsNull())
63 aistrihed = new AIS_Point(apt);
64 else {
65 aistrihed->SetComponent(apt);
66 aistrihed->ResetTransformation();
67 aistrihed->SetToUpdate();
68 aistrihed->UpdateSelection();
69 }
70 }
71 anAISObject = aistrihed;
72 return Standard_True;
73}
74