0027818: Visualization - provide an interface to define highlight presentation properties
[occt.git] / src / AIS / AIS_DimensionOwner.cxx
1 // Created on: 1996-12-05
2 // Created by: Odile Olivier
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
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>
23 #include <StdSelect_Shape.hxx>
24 #include <TopoDS.hxx>
25 #include <TopoDS_Vertex.hxx>
26
27 IMPLEMENT_STANDARD_RTTIEXT(AIS_DimensionOwner,SelectMgr_EntityOwner)
28
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   }
45 }
46
47 //=======================================================================
48 //function : Constructor
49 //purpose  : 
50 //=======================================================================
51 AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
52                                         const AIS_DimensionSelectionMode theMode,
53                                         const Standard_Integer thePriority)
54 : SelectMgr_EntityOwner(theSelObject, thePriority),
55   mySelectionMode (theMode)
56 {
57 }
58
59 //=======================================================================
60 //function : AIS_DimensionSelectionMode
61 //purpose  : 
62 //=======================================================================
63 AIS_DimensionSelectionMode AIS_DimensionOwner::SelectionMode () const
64 {
65   return mySelectionMode;
66 }
67
68 //=======================================================================
69 //function : IsHilighted
70 //purpose  : 
71 //=======================================================================
72 Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
73                                                   const Standard_Integer /*theMode*/) const
74 {
75   if (!HasSelectable())
76   {
77     return Standard_False;
78   }
79
80   return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode));
81 }
82
83 //=======================================================================
84 //function : Unhilight
85 //purpose  : 
86 //=======================================================================
87 void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
88                                     const Standard_Integer /*theMode*/)
89 {
90   if (!HasSelectable())
91   {
92     return;
93   }
94
95   thePM->Unhighlight (Selectable(), HighlightMode (mySelectionMode));
96 }
97
98 //=======================================================================
99 //function : HilightWithColor
100 //purpose  : 
101 //=======================================================================
102 void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
103                                            const Handle(Graphic3d_HighlightStyle)& theStyle,
104                                            const Standard_Integer /*theMode*/)
105 {
106   thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode));
107 }