b311480e |
1 | // Created on: 1996-12-05 |
2 | // Created by: Odile Olivier |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <AIS_DimensionOwner.ixx> |
a6eb515f |
24 | #include <AIS_DimensionDisplayMode.hxx> |
25 | #include <StdSelect_Shape.hxx> |
26 | #include <TopoDS.hxx> |
27 | #include <TopoDS_Vertex.hxx> |
7fd59977 |
28 | |
29 | |
a6eb515f |
30 | //======================================================================= |
31 | //function : Constructor |
32 | //purpose : |
33 | //======================================================================= |
7fd59977 |
34 | |
a6eb515f |
35 | AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, |
36 | const AIS_DimensionDisplayMode theMode, |
37 | const Standard_Integer thePriority) |
38 | : SelectMgr_EntityOwner(theSelObject, thePriority), |
39 | myDisplayMode (theMode) |
7fd59977 |
40 | { |
41 | } |
a6eb515f |
42 | |
43 | //======================================================================= |
44 | //function : SetDisplayMode |
45 | //purpose : |
46 | //======================================================================= |
47 | |
48 | void AIS_DimensionOwner::SetDisplayMode (const AIS_DimensionDisplayMode theMode) |
49 | { |
50 | myDisplayMode = theMode; |
51 | } |
52 | |
53 | //======================================================================= |
54 | //function : DisplayMode |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | AIS_DimensionDisplayMode AIS_DimensionOwner::DisplayMode () const |
59 | { |
60 | return myDisplayMode; |
61 | } |
62 | |
63 | //======================================================================= |
64 | //function : IsHilighted |
65 | //purpose : |
66 | //======================================================================= |
67 | |
68 | Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, |
69 | const Standard_Integer theMode) const |
70 | { |
71 | if (HasSelectable()) |
72 | { |
73 | Standard_Integer aMode = myDisplayMode != 0 ? myDisplayMode : theMode; |
74 | return thePM->IsHighlighted(Selectable (), aMode); |
75 | } |
76 | return Standard_False; |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : Hilight |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | void AIS_DimensionOwner::Hilight (const Handle(PrsMgr_PresentationManager)& thePM, |
85 | const Standard_Integer theMode) |
86 | { |
87 | if (HasSelectable()) |
88 | { |
89 | Standard_Integer aMode = myDisplayMode != 0 ? myDisplayMode : theMode; |
90 | thePM->Highlight (Selectable(),aMode); |
91 | } |
92 | } |
93 | |
94 | //======================================================================= |
95 | //function : Unhilight |
96 | //purpose : |
97 | //======================================================================= |
98 | |
99 | void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, |
100 | const Standard_Integer theMode) |
101 | { |
102 | if (HasSelectable()) |
103 | { |
104 | Standard_Integer aMode = myDisplayMode != 0 ? myDisplayMode : theMode; |
105 | thePM->Unhighlight(Selectable(),aMode); |
106 | } |
107 | } |
108 | |
109 | //======================================================================= |
110 | //function : HilightWithColor |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, |
115 | const Quantity_NameOfColor theColor, |
116 | const Standard_Integer theMode) |
117 | { |
118 | // Highlight selectable part of dimension with color |
119 | if (myDisplayMode != 0) |
120 | { |
121 | thePM->Color (Selectable(), theColor, myDisplayMode); |
122 | } |
123 | else |
124 | thePM->Color (Selectable(), theColor, theMode); |
125 | } |