1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : MeasureGUI_DimensionFilter.cxx
25 // Author : Anton POLETAEV, Open CASCADE S.A.S.
27 #include "MeasureGUI_DimensionFilter.h"
30 #include <GEOM_AISDimension.hxx>
33 #include <SALOME_InteractiveObject.hxx>
35 IMPLEMENT_STANDARD_RTTIEXT(MeasureGUI_DimensionFilter, SelectMgr_Filter)
37 //=======================================================================
38 // function : Constructor
40 //=======================================================================
41 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const Handle(AIS_InteractiveObject)& theIO )
46 myIsFilterIO( Standard_True ),
47 myIsFilterEntry( Standard_False ),
48 myIsFilterId( Standard_False )
52 //=======================================================================
53 // function : Constructor
55 //=======================================================================
56 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const int theId )
61 myIsFilterIO( Standard_False ),
62 myIsFilterEntry( Standard_False ),
63 myIsFilterId( Standard_True )
67 //=======================================================================
68 // function : Constructor
70 //=======================================================================
71 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const std::string& theEntry )
74 myFilterEntry( theEntry ),
76 myIsFilterIO( Standard_False ),
77 myIsFilterEntry( Standard_True ),
78 myIsFilterId( Standard_False )
82 //=======================================================================
83 // function : Constructor
85 //=======================================================================
86 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const std::string& theEntry, const int theId )
89 myFilterEntry( theEntry ),
91 myIsFilterIO( Standard_False ),
92 myIsFilterEntry( Standard_True ),
93 myIsFilterId( Standard_True )
97 //=======================================================================
98 // function : SetFilterIO
100 //=======================================================================
101 void MeasureGUI_DimensionFilter::SetFilterIO( const Handle(AIS_InteractiveObject)& theIO )
104 myIsFilterIO = Standard_True;
107 //=======================================================================
108 // function : SetFilterEntry
110 //=======================================================================
111 void MeasureGUI_DimensionFilter::SetFilterEntry( const std::string& theEntry )
113 myFilterEntry = theEntry;
114 myIsFilterEntry = Standard_True;
117 //=======================================================================
118 // function : SetFilterId
120 //=======================================================================
121 void MeasureGUI_DimensionFilter::SetFilterId( const int theId )
124 myIsFilterId = Standard_True;
127 //=======================================================================
130 //=======================================================================
131 Standard_Boolean MeasureGUI_DimensionFilter::IsOk( const Handle(SelectMgr_EntityOwner)& theEntity ) const
133 Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( theEntity->Selectable() );
135 if ( anAIS.IsNull() || !anAIS->HasOwner() )
137 return Standard_False;
140 if ( !anAIS->IsKind( STANDARD_TYPE( AIS_LengthDimension ) )
141 && !anAIS->IsKind( STANDARD_TYPE( AIS_DiameterDimension ) )
142 && !anAIS->IsKind( STANDARD_TYPE( AIS_AngleDimension ) ) )
144 return Standard_False;
149 if ( anAIS != myFilterIO )
151 return Standard_False;
155 if ( myIsFilterEntry )
157 Handle(SALOME_InteractiveObject) anIO = Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
160 return Standard_False;
163 if ( std::string( anIO->getEntry() ) != myFilterEntry )
165 return Standard_False;
171 Handle(GEOM_AISLength) aLength = Handle(GEOM_AISLength)::DownCast( anAIS );
172 if ( !aLength.IsNull() && aLength->GetId() != myFilterId )
174 return Standard_False;
177 Handle(GEOM_AISDiameter) aDiameter = Handle(GEOM_AISDiameter)::DownCast( anAIS );
178 if ( !aDiameter.IsNull() && aDiameter->GetId() != myFilterId )
180 return Standard_False;
183 Handle(GEOM_AISAngle) anAngle = Handle(GEOM_AISAngle)::DownCast( anAIS );
184 if ( !anAngle.IsNull() && anAngle->GetId() != myFilterId )
186 return Standard_False;
190 return Standard_True;