blob: 2d493a1880a790305cc18dd96f5862dd8e61dbcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// last modified by SRN 01/08/2000
#include <TPrsStd_NamedShapeDriver.ixx>
#include <TDF_Label.hxx>
#include <TNaming_NamedShape.hxx>
#include <AIS_Shape.hxx>
#include <AIS_InteractiveContext.hxx>
#include <TDataStd.hxx>
#include <Standard_GUID.hxx>
#include <TPrsStd_DriverTable.hxx>
#include <TNaming_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <PrsMgr_Presentation.hxx>
#include <Prs3d_Presentation.hxx>
#include <PrsMgr_Presentation3d.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <Geom_Transformation.hxx>
#undef OPTIM_UPDATE // If this variable is defined there will be done
// more otimized update of AIS_Shape. If an object was
// erased in the viewer and it's location was changed
// but topological data wasn't then when displayed only
// the object's presentation will be moved to new location
// without recompute. The shape in AIS_Shape will
// be the previous one with the old location.
// NOTE! After selection of sub shapes of the object
// they will have THE OLD LOCATION and it has to be
// compared with location of AIS_Shape that will contain
// the right location of shape.
//=======================================================================
//function :
//purpose :
//=======================================================================
TPrsStd_NamedShapeDriver::TPrsStd_NamedShapeDriver()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean TPrsStd_NamedShapeDriver::Update (const TDF_Label& aLabel,
Handle(AIS_InteractiveObject)& AIS)
{
Handle(TNaming_NamedShape) NS;
if( !aLabel.FindAttribute(TNaming_NamedShape::GetID(), NS) ) {
return Standard_False;
}
//TopoDS_Shape S = TNaming_Tool::CurrentShape (NS);
TopoDS_Shape S = TNaming_Tool::GetShape (NS);
if(S.IsNull()){
return Standard_False;
}
TopLoc_Location L = S.Location();
Handle(AIS_Shape) AISShape;
if (AIS.IsNull()) AISShape = new AIS_Shape(S);
else {
AISShape = Handle(AIS_Shape)::DownCast(AIS);
if (AISShape.IsNull()) {
AISShape = new AIS_Shape(S);
}
else {
TopoDS_Shape oldShape = AISShape->Shape();
if(oldShape != S) {
AISShape->ResetLocation();
#ifdef OPTIM_UPDATE
Handle(AIS_InteractiveContext) ctx = AISShape->GetContext();
if(S.IsPartner(oldShape) && (!ctx.IsNull() && !ctx->IsDisplayed(AISShape))) {
if(L != oldShape.Location()) ctx->SetLocation(AISShape, L);
}
else {
AISShape->Set(S);
AISShape->UpdateSelection();
AISShape->SetToUpdate();
}
#else
AISShape->Set(S);
AISShape->UpdateSelection();
AISShape->SetToUpdate();
#endif
}
}
AISShape->SetInfiniteState(S.Infinite());
}
AIS = AISShape;
return Standard_True;
}
|