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 | |
f838dac4 |
17 | #include <AIS_DimensionOwner.hxx> |
fe83e1ea |
18 | |
42cf5bc1 |
19 | #include <AIS_Dimension.hxx> |
42cf5bc1 |
20 | #include <PrsMgr_PresentationManager.hxx> |
21 | #include <SelectMgr_SelectableObject.hxx> |
22 | #include <Standard_Type.hxx> |
a6eb515f |
23 | #include <TopoDS.hxx> |
24 | #include <TopoDS_Vertex.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(AIS_DimensionOwner,SelectMgr_EntityOwner) |
27 | |
fe83e1ea |
28 | namespace |
29 | { |
30 | //======================================================================= |
31 | //function : HighlightMode |
32 | //purpose : Return corresponding compute mode for selection type. |
33 | //======================================================================= |
34 | static AIS_Dimension::ComputeMode HighlightMode (const Standard_Integer theSelMode) |
35 | { |
36 | switch (theSelMode) |
37 | { |
38 | case AIS_DSM_Line : return AIS_Dimension::ComputeMode_Line; |
39 | case AIS_DSM_Text : return AIS_Dimension::ComputeMode_Text; |
40 | default: |
41 | return AIS_Dimension::ComputeMode_All; |
42 | } |
43 | } |
a3f6f591 |
44 | } |
7fd59977 |
45 | |
a6eb515f |
46 | //======================================================================= |
47 | //function : Constructor |
48 | //purpose : |
49 | //======================================================================= |
a6eb515f |
50 | AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject, |
fe83e1ea |
51 | const AIS_DimensionSelectionMode theMode, |
a6eb515f |
52 | const Standard_Integer thePriority) |
53 | : SelectMgr_EntityOwner(theSelObject, thePriority), |
fe83e1ea |
54 | mySelectionMode (theMode) |
7fd59977 |
55 | { |
56 | } |
a6eb515f |
57 | |
58 | //======================================================================= |
fe83e1ea |
59 | //function : AIS_DimensionSelectionMode |
a6eb515f |
60 | //purpose : |
61 | //======================================================================= |
fe83e1ea |
62 | AIS_DimensionSelectionMode AIS_DimensionOwner::SelectionMode () const |
a6eb515f |
63 | { |
fe83e1ea |
64 | return mySelectionMode; |
a6eb515f |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : IsHilighted |
69 | //purpose : |
70 | //======================================================================= |
a6eb515f |
71 | Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM, |
fe83e1ea |
72 | const Standard_Integer /*theMode*/) const |
a6eb515f |
73 | { |
fe83e1ea |
74 | if (!HasSelectable()) |
a6eb515f |
75 | { |
fe83e1ea |
76 | return Standard_False; |
a6eb515f |
77 | } |
fe83e1ea |
78 | |
79 | return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode)); |
a6eb515f |
80 | } |
81 | |
a6eb515f |
82 | //======================================================================= |
83 | //function : Unhilight |
84 | //purpose : |
85 | //======================================================================= |
a6eb515f |
86 | void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM, |
fe83e1ea |
87 | const Standard_Integer /*theMode*/) |
a6eb515f |
88 | { |
fe83e1ea |
89 | if (!HasSelectable()) |
a6eb515f |
90 | { |
fe83e1ea |
91 | return; |
a6eb515f |
92 | } |
fe83e1ea |
93 | |
f838dac4 |
94 | thePM->Unhighlight (Selectable()); |
a6eb515f |
95 | } |
96 | |
97 | //======================================================================= |
98 | //function : HilightWithColor |
99 | //purpose : |
100 | //======================================================================= |
a6eb515f |
101 | void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, |
f838dac4 |
102 | const Handle(Prs3d_Drawer)& theStyle, |
fe83e1ea |
103 | const Standard_Integer /*theMode*/) |
a6eb515f |
104 | { |
8e5fb5ea |
105 | thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode)); |
a6eb515f |
106 | } |