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.
14 // last modified by SRN 01/08/2000
16 #include <AIS_InteractiveContext.hxx>
17 #include <AIS_InteractiveObject.hxx>
18 #include <AIS_Shape.hxx>
19 #include <Geom_Transformation.hxx>
20 #include <Prs3d_Presentation.hxx>
21 #include <PrsMgr_Presentation.hxx>
22 #include <PrsMgr_PresentationManager.hxx>
23 #include <Standard_GUID.hxx>
24 #include <Standard_Type.hxx>
25 #include <TColStd_ListIteratorOfListOfInteger.hxx>
26 #include <TColStd_ListOfInteger.hxx>
27 #include <TDataStd.hxx>
28 #include <TDF_Label.hxx>
29 #include <TNaming_NamedShape.hxx>
30 #include <TNaming_Tool.hxx>
31 #include <TopLoc_Location.hxx>
32 #include <TPrsStd_DriverTable.hxx>
33 #include <TPrsStd_NamedShapeDriver.hxx>
35 IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_NamedShapeDriver,TPrsStd_Driver)
37 #undef OPTIM_UPDATE // If this variable is defined there will be done
38 // more otimized update of AIS_Shape. If an object was
39 // erased in the viewer and it's location was changed
40 // but topological data wasn't then when displayed only
41 // the object's presentation will be moved to new location
42 // without recompute. The shape in AIS_Shape will
43 // be the previous one with the old location.
44 // NOTE! After selection of sub shapes of the object
45 // they will have THE OLD LOCATION and it has to be
46 // compared with location of AIS_Shape that will contain
47 // the right location of shape.
50 //=======================================================================
53 //=======================================================================
54 TPrsStd_NamedShapeDriver::TPrsStd_NamedShapeDriver()
58 //=======================================================================
61 //=======================================================================
62 Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel,
63 Handle(AIS_InteractiveObject)& AIS)
65 Handle(TNaming_NamedShape) NS;
67 if( !aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
68 return Standard_False;
71 //TopoDS_Shape S = TNaming_Tool::CurrentShape (NS);
72 TopoDS_Shape S = TNaming_Tool::GetShape (NS);
74 return Standard_False;
76 TopLoc_Location L = S.Location();
78 Handle(AIS_Shape) AISShape;
79 if (AIS.IsNull()) AISShape = new AIS_Shape(S);
81 AISShape = Handle(AIS_Shape)::DownCast(AIS);
82 if (AISShape.IsNull()) {
83 AISShape = new AIS_Shape(S);
86 TopoDS_Shape oldShape = AISShape->Shape();
88 AISShape->ResetTransformation();
91 Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();
92 if(S.IsPartner(oldShape) && (!ctx.IsNull() && !ctx->IsDisplayed(AISShape))) {
93 if(L != oldShape.Location()) ctx->SetLocation(AISShape, L);
97 AISShape->UpdateSelection();
98 AISShape->SetToUpdate();
102 AISShape->UpdateSelection();
103 AISShape->SetToUpdate();
108 AISShape->SetInfiniteState(S.Infinite());
111 return Standard_True;