0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / AIS / AIS_DimensionOwner.cxx
CommitLineData
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
fe83e1ea 27namespace
28{
29 //=======================================================================
30 //function : HighlightMode
31 //purpose : Return corresponding compute mode for selection type.
32 //=======================================================================
33 static AIS_Dimension::ComputeMode HighlightMode (const Standard_Integer theSelMode)
34 {
35 switch (theSelMode)
36 {
37 case AIS_DSM_Line : return AIS_Dimension::ComputeMode_Line;
38 case AIS_DSM_Text : return AIS_Dimension::ComputeMode_Text;
39 default:
40 return AIS_Dimension::ComputeMode_All;
41 }
42 }
43};
7fd59977 44
a6eb515f 45//=======================================================================
46//function : Constructor
47//purpose :
48//=======================================================================
a6eb515f 49AIS_DimensionOwner::AIS_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
fe83e1ea 50 const AIS_DimensionSelectionMode theMode,
a6eb515f 51 const Standard_Integer thePriority)
52: SelectMgr_EntityOwner(theSelObject, thePriority),
fe83e1ea 53 mySelectionMode (theMode)
7fd59977 54{
55}
a6eb515f 56
57//=======================================================================
fe83e1ea 58//function : AIS_DimensionSelectionMode
a6eb515f 59//purpose :
60//=======================================================================
fe83e1ea 61AIS_DimensionSelectionMode AIS_DimensionOwner::SelectionMode () const
a6eb515f 62{
fe83e1ea 63 return mySelectionMode;
a6eb515f 64}
65
66//=======================================================================
67//function : IsHilighted
68//purpose :
69//=======================================================================
a6eb515f 70Standard_Boolean AIS_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
fe83e1ea 71 const Standard_Integer /*theMode*/) const
a6eb515f 72{
fe83e1ea 73 if (!HasSelectable())
a6eb515f 74 {
fe83e1ea 75 return Standard_False;
a6eb515f 76 }
fe83e1ea 77
78 return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode));
a6eb515f 79}
80
81//=======================================================================
82//function : Hilight
83//purpose :
84//=======================================================================
a6eb515f 85void AIS_DimensionOwner::Hilight (const Handle(PrsMgr_PresentationManager)& thePM,
fe83e1ea 86 const Standard_Integer /*theMode*/)
a6eb515f 87{
fe83e1ea 88 if (!HasSelectable())
a6eb515f 89 {
fe83e1ea 90 return;
a6eb515f 91 }
fe83e1ea 92
93 thePM->Highlight (Selectable(), HighlightMode (mySelectionMode));
a6eb515f 94}
95
96//=======================================================================
97//function : Unhilight
98//purpose :
99//=======================================================================
a6eb515f 100void AIS_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
fe83e1ea 101 const Standard_Integer /*theMode*/)
a6eb515f 102{
fe83e1ea 103 if (!HasSelectable())
a6eb515f 104 {
fe83e1ea 105 return;
a6eb515f 106 }
fe83e1ea 107
108 thePM->Unhighlight (Selectable(), HighlightMode (mySelectionMode));
a6eb515f 109}
110
111//=======================================================================
112//function : HilightWithColor
113//purpose :
114//=======================================================================
a6eb515f 115void AIS_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
116 const Quantity_NameOfColor theColor,
fe83e1ea 117 const Standard_Integer /*theMode*/)
a6eb515f 118{
fe83e1ea 119 thePM->Color (Selectable(), theColor, HighlightMode (mySelectionMode));
a6eb515f 120}