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