0024837: Visualization - revise design and implementation of connected Interactive...
[occt.git] / src / TPrsStd / TPrsStd_PlaneDriver.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 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
973c2be1 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.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <TPrsStd_PlaneDriver.ixx>
15
16#include <TDF_Label.hxx>
17#include <TDataXtd_Plane.hxx>
18//#include <TDataStd_Datum.hxx>
19#include <TDataXtd_Geometry.hxx>
20#include <AIS_Plane.hxx>
21#include <AIS_Drawer.hxx>
22#include <AIS_InteractiveContext.hxx>
23#include <TNaming_NamedShape.hxx>
24#include <TNaming_Tool.hxx>
25#include <Geom_Plane.hxx>
26#include <gp_Pln.hxx>
27
28//=======================================================================
29//function :
30//purpose :
31//=======================================================================
32TPrsStd_PlaneDriver::TPrsStd_PlaneDriver()
33{
34}
35
36//=======================================================================
37//function :
38//purpose :
39//=======================================================================
40Standard_Boolean TPrsStd_PlaneDriver::Update (const TDF_Label& aLabel,
41 Handle(AIS_InteractiveObject)& anAISObject)
42{
43 Handle(TDataXtd_Plane) apPlane;
44
45 if ( !aLabel.FindAttribute(TDataXtd_Plane::GetID(), apPlane) ) {
46 return Standard_False;
47 }
48
49 gp_Pln pln;
50 if (!TDataXtd_Geometry::Plane(aLabel,pln)) {
51 return Standard_False;
52 }
53 Handle(Geom_Plane) apt = new Geom_Plane(pln);
54
55 // Update AIS
56 Handle(AIS_Plane) aisplane;
57 if (anAISObject.IsNull())
58 aisplane = new AIS_Plane(apt,pln.Location());
59 else {
60 aisplane = Handle(AIS_Plane)::DownCast(anAISObject);
61 if (aisplane.IsNull())
62 aisplane = new AIS_Plane(apt,pln.Location());
63 else {
64 aisplane->SetComponent(apt);
65 aisplane->SetCenter(pln.Location());
0717ddc1 66 aisplane->ResetTransformation();
7fd59977 67 aisplane->SetToUpdate();
68 aisplane->UpdateSelection();
69 }
70 }
71 anAISObject = aisplane;
72 return Standard_True;
73}
74