Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:15:45

0001 // Created on: 1997-03-04
0002 // Created by: Robert COUBLANC
0003 // Copyright (c) 1997-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _AIS_AttributeFilter_HeaderFile
0018 #define _AIS_AttributeFilter_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Quantity_NameOfColor.hxx>
0024 #include <Standard_Real.hxx>
0025 #include <SelectMgr_Filter.hxx>
0026 class SelectMgr_EntityOwner;
0027 
0028 class AIS_AttributeFilter;
0029 DEFINE_STANDARD_HANDLE(AIS_AttributeFilter, SelectMgr_Filter)
0030 
0031 //! Selects Interactive Objects, which have the desired width or color.
0032 //! The filter questions each Interactive Object in local
0033 //! context to determine whether it has an non-null
0034 //! owner, and if so, whether it has the required color
0035 //! and width attributes. If the object returns true in each
0036 //! case, it is kept. If not, it is rejected.
0037 //! This filter is used only in an open local context.
0038 //! In the Collector viewer, you can only locate
0039 //! Interactive Objects, which answer positively to the
0040 //! filters, which are in position when a local context is open.
0041 class AIS_AttributeFilter : public SelectMgr_Filter
0042 {
0043 public:
0044   //! Constructs an empty attribute filter object.
0045   //! This filter object determines whether selectable
0046   //! interactive objects have a non-null owner.
0047   Standard_EXPORT AIS_AttributeFilter();
0048 
0049   //! Constructs an attribute filter object defined by the
0050   //! color attribute aCol.
0051   Standard_EXPORT AIS_AttributeFilter(const Quantity_NameOfColor aCol);
0052 
0053   //! Constructs an attribute filter object defined by the line
0054   //! width attribute aWidth.
0055   Standard_EXPORT AIS_AttributeFilter(const Standard_Real aWidth);
0056 
0057   //! Indicates that the Interactive Object has the color
0058   //! setting specified by the argument aCol at construction time.
0059   Standard_Boolean HasColor() const { return hasC; }
0060 
0061   //! Indicates that the Interactive Object has the width
0062   //! setting specified by the argument aWidth at
0063   //! construction time.
0064   Standard_Boolean HasWidth() const { return hasW; }
0065 
0066   //! Sets the color.
0067   void SetColor(const Quantity_NameOfColor theCol)
0068   {
0069     myCol = theCol;
0070     hasC  = Standard_True;
0071   }
0072 
0073   //! Sets the line width.
0074   void SetWidth(const Standard_Real theWidth)
0075   {
0076     myWid = theWidth;
0077     hasW  = Standard_True;
0078   }
0079 
0080   //! Removes the setting for color from the filter.
0081   void UnsetColor() { hasC = Standard_False; }
0082 
0083   //! Removes the setting for width from the filter.
0084   void UnsetWidth() { hasW = Standard_False; }
0085 
0086   //! Indicates that the selected Interactive Object passes
0087   //! the filter. The owner, anObj, can be either direct or
0088   //! user. A direct owner is the corresponding
0089   //! construction element, whereas a user is the
0090   //! compound shape of which the entity forms a part.
0091   //! If the Interactive Object returns Standard_True
0092   //! when detected by the Local Context selector through
0093   //! the mouse, the object is kept; if not, it is rejected.
0094   Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& anObj) const
0095     Standard_OVERRIDE;
0096 
0097   DEFINE_STANDARD_RTTIEXT(AIS_AttributeFilter, SelectMgr_Filter)
0098 
0099 private:
0100   Quantity_NameOfColor myCol;
0101   Standard_Real        myWid;
0102   Standard_Boolean     hasC;
0103   Standard_Boolean     hasW;
0104 };
0105 
0106 #endif // _AIS_AttributeFilter_HeaderFile