1 // Copyright (C) 2007-2013 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.
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_HANDLE (MeasureGUI_DimensionFilter, SelectMgr_Filter)
36 IMPLEMENT_STANDARD_RTTIEXT(MeasureGUI_DimensionFilter, SelectMgr_Filter)
38 //=======================================================================
39 // function : Constructor
41 //=======================================================================
42 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const Handle(AIS_InteractiveObject)& theIO )
47 myIsFilterIO( Standard_True ),
48 myIsFilterEntry( Standard_False ),
49 myIsFilterId( Standard_False )
53 //=======================================================================
54 // function : Constructor
56 //=======================================================================
57 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const int theId )
62 myIsFilterIO( Standard_False ),
63 myIsFilterEntry( Standard_False ),
64 myIsFilterId( Standard_True )
68 //=======================================================================
69 // function : Constructor
71 //=======================================================================
72 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const std::string& theEntry )
75 myFilterEntry( theEntry ),
77 myIsFilterIO( Standard_False ),
78 myIsFilterEntry( Standard_True ),
79 myIsFilterId( Standard_False )
83 //=======================================================================
84 // function : Constructor
86 //=======================================================================
87 MeasureGUI_DimensionFilter::MeasureGUI_DimensionFilter( const std::string& theEntry, const int theId )
90 myFilterEntry( theEntry ),
92 myIsFilterIO( Standard_False ),
93 myIsFilterEntry( Standard_True ),
94 myIsFilterId( Standard_True )
98 //=======================================================================
99 // function : SetFilterIO
101 //=======================================================================
102 void MeasureGUI_DimensionFilter::SetFilterIO( const Handle(AIS_InteractiveObject)& theIO )
105 myIsFilterIO = Standard_True;
108 //=======================================================================
109 // function : SetFilterEntry
111 //=======================================================================
112 void MeasureGUI_DimensionFilter::SetFilterEntry( const std::string& theEntry )
114 myFilterEntry = theEntry;
115 myIsFilterEntry = Standard_True;
118 //=======================================================================
119 // function : SetFilterId
121 //=======================================================================
122 void MeasureGUI_DimensionFilter::SetFilterId( const int theId )
125 myIsFilterId = Standard_True;
128 //=======================================================================
131 //=======================================================================
132 Standard_Boolean MeasureGUI_DimensionFilter::IsOk( const Handle(SelectMgr_EntityOwner)& theEntity ) const
134 Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( theEntity->Selectable() );
136 if ( anAIS.IsNull() || !anAIS->HasOwner() )
138 return Standard_False;
141 if ( !anAIS->IsKind( STANDARD_TYPE( AIS_LengthDimension ) )
142 && !anAIS->IsKind( STANDARD_TYPE( AIS_DiameterDimension ) )
143 && !anAIS->IsKind( STANDARD_TYPE( AIS_AngleDimension ) ) )
145 return Standard_False;
150 if ( anAIS != myFilterIO )
152 return Standard_False;
156 if ( myIsFilterEntry )
158 Handle(SALOME_InteractiveObject) anIO = Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
161 return Standard_False;
164 if ( std::string( anIO->getEntry() ) != myFilterEntry )
166 return Standard_False;
172 Handle(GEOM_AISLength) aLength = Handle(GEOM_AISLength)::DownCast( anAIS );
173 if ( !aLength.IsNull() && aLength->GetId() != myFilterId )
175 return Standard_False;
178 Handle(GEOM_AISDiameter) aDiameter = Handle(GEOM_AISDiameter)::DownCast( anAIS );
179 if ( !aDiameter.IsNull() && aDiameter->GetId() != myFilterId )
181 return Standard_False;
184 Handle(GEOM_AISAngle) anAngle = Handle(GEOM_AISAngle)::DownCast( anAIS );
185 if ( !anAngle.IsNull() && anAngle->GetId() != myFilterId )
187 return Standard_False;
191 return Standard_True;