summaryrefslogtreecommitdiff
path: root/src/StdSelect/StdSelect_BRepOwner.cxx
blob: 7e3bd1bf79a1142ee8dd25560f8bf80f51909de1 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright: 	Matra-Datavision 1995
// File:	StdSelect_BRepOwner.cxx
// Created:	Wed Mar  8 16:13:35 1995
// Author:	Mister rmi
//		<rmi>

#define BUC60876	//GG_050401 Enable to highlight something
//			with a specific hilight mode
//

#include <StdSelect_BRepOwner.ixx>
#include <SelectBasics_EntityOwner.hxx>

#include <StdPrs_WFShape.hxx>

#include <Graphic3d_StructureManager.hxx>

//==================================================
// Function: 
// Purpose :
//==================================================
StdSelect_BRepOwner::StdSelect_BRepOwner(const Standard_Integer aPriority):
SelectMgr_EntityOwner(aPriority),
myFromDecomposition(Standard_False),
myCurMode(0)
{
}

StdSelect_BRepOwner::StdSelect_BRepOwner(const TopoDS_Shape& aShape,
					 const Standard_Integer aPriority,
					 const Standard_Boolean ComesFromDecomposition):
SelectMgr_EntityOwner(aPriority),
myFromDecomposition(ComesFromDecomposition),
myShape(aShape),
myCurMode(0)
{
}

StdSelect_BRepOwner::StdSelect_BRepOwner(const TopoDS_Shape& aShape,
					 const Handle (SelectMgr_SelectableObject)& theOrigin,
					 const Standard_Integer aPriority,
					 const Standard_Boolean ComesFromDecomposition):
SelectMgr_EntityOwner(theOrigin,aPriority),
myFromDecomposition(ComesFromDecomposition),
myShape(aShape),
myCurMode(0)
{
}

//=======================================================================
//function : IsHilighted
//purpose  : 
//=======================================================================
Standard_Boolean StdSelect_BRepOwner::
IsHilighted(const Handle(PrsMgr_PresentationManager)& PM,
	    const Standard_Integer aMode) const 
{
#ifdef BUC60876
  Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
  Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
  if(myPrsSh.IsNull())
    return PM->IsHighlighted(Selectable(),M);
  return PM->IsHighlighted(myPrsSh,M);
}

//=======================================================================
//function : Hilight/Unhilight Methods...
//purpose  : 
//=======================================================================
void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
				  const Standard_Integer aMode)
{
  
#ifdef BUC60876
  Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
  Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
  if(myFromDecomposition)
    if(myPrsSh.IsNull())
      myPrsSh = new StdSelect_Shape(myShape);
  
  if(myPrsSh.IsNull())
    PM->Highlight(Selectable(),M);
  else
    PM->Highlight(myPrsSh,M);
}

void StdSelect_BRepOwner::Hilight()
{}

void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager3d)& PM,
					   const Quantity_NameOfColor aCol,
					   const Standard_Integer aMode)
{
#ifdef BUC60876
  Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
  Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
  if(myFromDecomposition){
    if(myPrsSh.IsNull()){
      if(HasLocation()){
	TopLoc_Location lbid = Location() * myShape.Location();
	TopoDS_Shape ShBis = myShape.Located(lbid);
	myPrsSh = new StdSelect_Shape(ShBis);
      }
      else
	myPrsSh = new StdSelect_Shape(myShape);
    }
  }
  if(myPrsSh.IsNull())
    PM->Color(Selectable(),aCol,M);
  else
    PM->Color(myPrsSh,aCol,M);
}

void StdSelect_BRepOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
				    const Standard_Integer aMode)
{
#ifdef BUC60876
  Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
  Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
  if(myPrsSh.IsNull() || !myFromDecomposition)
    PM->Unhighlight(Selectable(),M);
  else
    PM->Unhighlight(myPrsSh,M);
}

void StdSelect_BRepOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM,
				const Standard_Integer aMode)
{
#ifdef BUC60876
  Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
  Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
  if (!myPrsSh.IsNull())
    PM->Clear(myPrsSh,M);
  myPrsSh.Nullify();
}

void StdSelect_BRepOwner::SetLocation(const TopLoc_Location& aLoc)
{
  SelectMgr_EntityOwner::SetLocation(aLoc);
  if(!myPrsSh.IsNull())
    myPrsSh.Nullify();
  
}
void StdSelect_BRepOwner::ResetLocation()
{
  SelectMgr_EntityOwner::ResetLocation();
  if(!myPrsSh.IsNull())
    myPrsSh.Nullify(); 
}