b311480e |
1 | // Created on: 1996-12-05 |
2 | // Created by: Odile Olivier |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
fe83e1ea |
17 | |
42cf5bc1 |
18 | #include <AIS_Dimension.hxx> |
19 | #include <AIS_DimensionOwner.hxx> |
20 | #include <PrsMgr_PresentationManager.hxx> |
21 | #include <SelectMgr_SelectableObject.hxx> |
22 | #include <Standard_Type.hxx> |
a6eb515f |
23 | #include <StdSelect_Shape.hxx> |
24 | #include <TopoDS.hxx> |
25 | #include <TopoDS_Vertex.hxx> |
7fd59977 |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(AIS_DimensionOwner,SelectMgr_EntityOwner) |
28 | |
fe83e1ea |
29 | namespace |
30 | { |
31 | //======================================================================= |
32 | //function : HighlightMode |
33 | //purpose : Return corresponding compute mode for selection type. |
34 | //======================================================================= |
35 | static AIS_Dimension::ComputeMode HighlightMode (const Standard_Integer theSelMode) |
36 | { |
37 | switch (theSelMode) |
38 | { |
39 | case AIS_DSM_Line : return AIS_Dimension::ComputeMode_Line; |
40 | case AIS_DSM_Text : return AIS_Dimension::ComputeMode_Text; |
41 | default: |
42 | return AIS_Dimension::ComputeMode_All; |
43 | } |
44 | } |
a3f6f591 |
45 | } |
7fd59977 |
46 | |
a6eb515f |
47 | //======================================================================= |
48 | //function : Constructor |
49 | //purpose : |
50 | //======================================================================= |
a6eb515f |
51 | AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, |
fe83e1ea |
52 | const AIS_DimensionSelectionMode theMode, |
a6eb515f |
53 | const Standard_Integer thePriority) |
54 | : SelectMgr_EntityOwner(theSelObject, thePriority), |
fe83e1ea |
55 | mySelectionMode (theMode) |
7fd59977 |
56 | { |
57 | } |
a6eb515f |
58 | |
59 | //======================================================================= |
fe83e1ea |
60 | //function : AIS_DimensionSelectionMode |
a6eb515f |
61 | //purpose : |
62 | //======================================================================= |
fe83e1ea |
63 | AIS_DimensionSelectionMode AIS_DimensionOwner::SelectionMode () const |
a6eb515f |
64 | { |
fe83e1ea |
65 | return mySelectionMode; |
a6eb515f |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : IsHilighted |
70 | //purpose : |
71 | //======================================================================= |
a6eb515f |
72 | Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, |
fe83e1ea |
73 | const Standard_Integer /*theMode*/) const |
a6eb515f |
74 | { |
fe83e1ea |
75 | if (!HasSelectable()) |
a6eb515f |
76 | { |
fe83e1ea |
77 | return Standard_False; |
a6eb515f |
78 | } |
fe83e1ea |
79 | |
80 | return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode)); |
a6eb515f |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : Hilight |
85 | //purpose : |
86 | //======================================================================= |
a6eb515f |
87 | void AIS_DimensionOwner::Hilight (const Handle(PrsMgr_PresentationManager)& thePM, |
fe83e1ea |
88 | const Standard_Integer /*theMode*/) |
a6eb515f |
89 | { |
fe83e1ea |
90 | if (!HasSelectable()) |
a6eb515f |
91 | { |
fe83e1ea |
92 | return; |
a6eb515f |
93 | } |
fe83e1ea |
94 | |
95 | thePM->Highlight (Selectable(), HighlightMode (mySelectionMode)); |
a6eb515f |
96 | } |
97 | |
98 | //======================================================================= |
99 | //function : Unhilight |
100 | //purpose : |
101 | //======================================================================= |
a6eb515f |
102 | void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, |
fe83e1ea |
103 | const Standard_Integer /*theMode*/) |
a6eb515f |
104 | { |
fe83e1ea |
105 | if (!HasSelectable()) |
a6eb515f |
106 | { |
fe83e1ea |
107 | return; |
a6eb515f |
108 | } |
fe83e1ea |
109 | |
110 | thePM->Unhighlight (Selectable(), HighlightMode (mySelectionMode)); |
a6eb515f |
111 | } |
112 | |
113 | //======================================================================= |
114 | //function : HilightWithColor |
115 | //purpose : |
116 | //======================================================================= |
a6eb515f |
117 | void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, |
118 | const Quantity_NameOfColor theColor, |
fe83e1ea |
119 | const Standard_Integer /*theMode*/) |
a6eb515f |
120 | { |
fe83e1ea |
121 | thePM->Color (Selectable(), theColor, HighlightMode (mySelectionMode)); |
a6eb515f |
122 | } |