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 <Prs3d_Presentation.hxx>
20 #include <PrsMgr_Presentation.hxx>
21 #include <PrsMgr_PresentationManager.hxx>
22 #include <Standard_GUID.hxx>
23 #include <Standard_Type.hxx>
24 #include <TColStd_ListIteratorOfListOfInteger.hxx>
25 #include <TColStd_ListOfInteger.hxx>
26 #include <TDataStd.hxx>
27 #include <TDF_Label.hxx>
28 #include <TNaming_NamedShape.hxx>
29 #include <TNaming_Tool.hxx>
30 #include <TopLoc_Location.hxx>
31 #include <TPrsStd_DriverTable.hxx>
32 #include <TPrsStd_NamedShapeDriver.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(TPrsStd_NamedShapeDriver,TPrsStd_Driver)
36 #undef OPTIM_UPDATE // If this variable is defined there will be done
37 // more otimized update of AIS_Shape. If an object was
38 // erased in the viewer and it's location was changed
39 // but topological data wasn't then when displayed only
40 // the object's presentation will be moved to new location
41 // without recompute. The shape in AIS_Shape will
42 // be the previous one with the old location.
43 // NOTE! After selection of sub shapes of the object
44 // they will have THE OLD LOCATION and it has to be
45 // compared with location of AIS_Shape that will contain
46 // the right location of shape.
49 //=======================================================================
52 //=======================================================================
53 TPrsStd_NamedShapeDriver::TPrsStd_NamedShapeDriver()
57 //=======================================================================
60 //=======================================================================
61 Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel,
62 Handle(AIS_InteractiveObject)& AIS)
64 Handle(TNaming_NamedShape) NS;
66 if( !aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
67 return Standard_False;
70 //TopoDS_Shape S = TNaming_Tool::CurrentShape (NS);
71 TopoDS_Shape S = TNaming_Tool::GetShape (NS);
73 return Standard_False;
75 TopLoc_Location L = S.Location();
77 Handle(AIS_Shape) AISShape;
78 if (AIS.IsNull()) AISShape = new AIS_Shape(S);
80 AISShape = Handle(AIS_Shape)::DownCast(AIS);
81 if (AISShape.IsNull()) {
82 AISShape = new AIS_Shape(S);
85 TopoDS_Shape oldShape = AISShape->Shape();
87 AISShape->ResetTransformation();
90 Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();
91 if(S.IsPartner(oldShape) && (!ctx.IsNull() && !ctx->IsDisplayed(AISShape))) {
92 if(L != oldShape.Location()) ctx->SetLocation(AISShape, L);
96 AISShape->UpdateSelection();
97 AISShape->SetToUpdate();
101 AISShape->UpdateSelection();
102 AISShape->SetToUpdate();
107 AISShape->SetInfiniteState(S.Infinite());
110 return Standard_True;