0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
[occt.git] / src / PrsDim / PrsDim_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
787ff240 17#include <PrsDim_DimensionOwner.hxx>
fe83e1ea 18
787ff240 19#include <PrsDim_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
787ff240 26IMPLEMENT_STANDARD_RTTIEXT(PrsDim_DimensionOwner, SelectMgr_EntityOwner)
92efcf78 27
fe83e1ea 28namespace
29{
30 //=======================================================================
31 //function : HighlightMode
32 //purpose : Return corresponding compute mode for selection type.
33 //=======================================================================
787ff240 34 static PrsDim_Dimension::ComputeMode HighlightMode (const Standard_Integer theSelMode)
fe83e1ea 35 {
36 switch (theSelMode)
37 {
787ff240 38 case PrsDim_DimensionSelectionMode_Line: return PrsDim_Dimension::ComputeMode_Line;
39 case PrsDim_DimensionSelectionMode_Text: return PrsDim_Dimension::ComputeMode_Text;
fe83e1ea 40 default:
787ff240 41 return PrsDim_Dimension::ComputeMode_All;
fe83e1ea 42 }
43 }
a3f6f591 44}
7fd59977 45
a6eb515f 46//=======================================================================
47//function : Constructor
48//purpose :
49//=======================================================================
787ff240 50PrsDim_DimensionOwner::PrsDim_DimensionOwner (const Handle(SelectMgr_SelectableObject)& theSelObject,
51 const PrsDim_DimensionSelectionMode theMode,
52 const Standard_Integer thePriority)
a6eb515f 53: SelectMgr_EntityOwner(theSelObject, thePriority),
fe83e1ea 54 mySelectionMode (theMode)
7fd59977 55{
56}
a6eb515f 57
58//=======================================================================
a6eb515f 59//function : IsHilighted
60//purpose :
61//=======================================================================
787ff240 62Standard_Boolean PrsDim_DimensionOwner::IsHilighted (const Handle(PrsMgr_PresentationManager)& thePM,
63 const Standard_Integer /*theMode*/) const
a6eb515f 64{
fe83e1ea 65 if (!HasSelectable())
a6eb515f 66 {
fe83e1ea 67 return Standard_False;
a6eb515f 68 }
fe83e1ea 69
70 return thePM->IsHighlighted (Selectable(), HighlightMode (mySelectionMode));
a6eb515f 71}
72
73//=======================================================================
a6eb515f 74//function : Unhilight
75//purpose :
76//=======================================================================
787ff240 77void PrsDim_DimensionOwner::Unhilight (const Handle(PrsMgr_PresentationManager)& thePM,
78 const Standard_Integer /*theMode*/)
a6eb515f 79{
fe83e1ea 80 if (!HasSelectable())
a6eb515f 81 {
fe83e1ea 82 return;
a6eb515f 83 }
fe83e1ea 84
f838dac4 85 thePM->Unhighlight (Selectable());
a6eb515f 86}
87
88//=======================================================================
89//function : HilightWithColor
90//purpose :
91//=======================================================================
787ff240 92void PrsDim_DimensionOwner::HilightWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
93 const Handle(Prs3d_Drawer)& theStyle,
94 const Standard_Integer /*theMode*/)
a6eb515f 95{
8e5fb5ea 96 thePM->Color (Selectable(), theStyle, HighlightMode (mySelectionMode));
a6eb515f 97}