1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 // last modified by SRN 01/08/2000
20 #include <TPrsStd_NamedShapeDriver.ixx>
22 #include <TDF_Label.hxx>
23 #include <TNaming_NamedShape.hxx>
24 #include <AIS_Shape.hxx>
25 #include <AIS_InteractiveContext.hxx>
26 #include <TDataStd.hxx>
27 #include <Standard_GUID.hxx>
28 #include <TPrsStd_DriverTable.hxx>
29 #include <TNaming_Tool.hxx>
30 #include <TopLoc_Location.hxx>
31 #include <TColStd_ListOfInteger.hxx>
32 #include <TColStd_ListIteratorOfListOfInteger.hxx>
33 #include <PrsMgr_Presentation.hxx>
34 #include <Prs3d_Presentation.hxx>
35 #include <PrsMgr_Presentation3d.hxx>
36 #include <PrsMgr_PresentationManager3d.hxx>
37 #include <Geom_Transformation.hxx>
39 #undef OPTIM_UPDATE // If this variable is defined there will be done
40 // more otimized update of AIS_Shape. If an object was
41 // erased in the viewer and it's location was changed
42 // but topological data wasn't then when displayed only
43 // the object's presentation will be moved to new location
44 // without recompute. The shape in AIS_Shape will
45 // be the previous one with the old location.
46 // NOTE! After selection of sub shapes of the object
47 // they will have THE OLD LOCATION and it has to be
48 // compared with location of AIS_Shape that will contain
49 // the right location of shape.
52 //=======================================================================
55 //=======================================================================
56 TPrsStd_NamedShapeDriver::TPrsStd_NamedShapeDriver()
60 //=======================================================================
63 //=======================================================================
64 Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel,
65 Handle(AIS_InteractiveObject)& AIS)
67 Handle(TNaming_NamedShape) NS;
69 if( !aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
70 return Standard_False;
73 //TopoDS_Shape S = TNaming_Tool::CurrentShape (NS);
74 TopoDS_Shape S = TNaming_Tool::GetShape (NS);
76 return Standard_False;
78 TopLoc_Location L = S.Location();
80 Handle(AIS_Shape) AISShape;
81 if (AIS.IsNull()) AISShape = new AIS_Shape(S);
83 AISShape = Handle(AIS_Shape)::DownCast(AIS);
84 if (AISShape.IsNull()) {
85 AISShape = new AIS_Shape(S);
88 TopoDS_Shape oldShape = AISShape->Shape();
90 AISShape->ResetLocation();
93 Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();
94 if(S.IsPartner(oldShape) && (!ctx.IsNull() && !ctx->IsDisplayed(AISShape))) {
95 if(L != oldShape.Location()) ctx->SetLocation(AISShape, L);
99 AISShape->UpdateSelection();
100 AISShape->SetToUpdate();
104 AISShape->UpdateSelection();
105 AISShape->SetToUpdate();
110 AISShape->SetInfiniteState(S.Infinite());
113 return Standard_True;