|
||||
File indexing completed on 2025-01-18 10:02:55
0001 // Created on: 2015-11-23 0002 // Created by: Anastasia BORISOVA 0003 // Copyright (c) 2015 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef _AIS_RubberBand_HeaderFile 0017 #define _AIS_RubberBand_HeaderFile 0018 0019 #include <AIS_InteractiveObject.hxx> 0020 #include <Graphic3d_ArrayOfPolylines.hxx> 0021 #include <Graphic3d_ArrayOfTriangles.hxx> 0022 #include <Graphic3d_Vec2.hxx> 0023 #include <NCollection_Sequence.hxx> 0024 0025 DEFINE_STANDARD_HANDLE(AIS_RubberBand, AIS_InteractiveObject) 0026 0027 //! Presentation for drawing rubber band selection. 0028 //! It supports rectangle and polygonal selection. 0029 //! It is constructed in 2d overlay. 0030 //! Default configuration is built without filling. 0031 //! For rectangle selection use SetRectangle() method. 0032 //! For polygonal selection use AddPoint() and GetPoints() methods. 0033 class AIS_RubberBand : public AIS_InteractiveObject 0034 { 0035 public: 0036 0037 DEFINE_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject) 0038 0039 //! Constructs rubber band with default configuration: empty filling and white solid lines. 0040 //! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer. 0041 Standard_EXPORT AIS_RubberBand(); 0042 0043 //! Consructs the rubber band with empty filling and defined line style. 0044 //! @param theLineColor [in] color of rubber band lines 0045 //! @param theType [in] type of rubber band lines 0046 //! @param theLineWidth [in] width of rubber band line. By default it is 1. 0047 //! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer. 0048 Standard_EXPORT AIS_RubberBand (const Quantity_Color& theLineColor, 0049 const Aspect_TypeOfLine theType, 0050 const Standard_Real theLineWidth = 1.0, 0051 const Standard_Boolean theIsPolygonClosed = Standard_True); 0052 0053 //! Constructs the rubber band with defined filling and line parameters. 0054 //! @param theLineColor [in] color of rubber band lines 0055 //! @param theType [in] type of rubber band lines 0056 //! @param theFillColor [in] color of rubber band filling 0057 //! @param theTransparency [in] transparency of the filling. 0 is for opaque filling. By default it is transparent. 0058 //! @param theLineWidth [in] width of rubber band line. By default it is 1. 0059 //! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer. 0060 Standard_EXPORT AIS_RubberBand (const Quantity_Color& theLineColor, 0061 const Aspect_TypeOfLine theType, 0062 const Quantity_Color theFillColor, 0063 const Standard_Real theTransparency = 1.0, 0064 const Standard_Real theLineWidth = 1.0, 0065 const Standard_Boolean theIsPolygonClosed = Standard_True); 0066 0067 Standard_EXPORT virtual ~AIS_RubberBand(); 0068 0069 //! Sets rectangle bounds. 0070 Standard_EXPORT void SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY, 0071 const Standard_Integer theMaxX, const Standard_Integer theMaxY); 0072 0073 //! Adds last point to the list of points. They are used to build polygon for rubber band. 0074 //! @sa RemoveLastPoint(), GetPoints() 0075 Standard_EXPORT void AddPoint (const Graphic3d_Vec2i& thePoint); 0076 0077 //! Remove last point from the list of points for the rubber band polygon. 0078 //! @sa AddPoint(), GetPoints() 0079 Standard_EXPORT void RemoveLastPoint(); 0080 0081 //! @return points for the rubber band polygon. 0082 Standard_EXPORT const NCollection_Sequence<Graphic3d_Vec2i>& Points() const; 0083 0084 //! Remove all points for the rubber band polygon. 0085 void ClearPoints() { myPoints.Clear(); } 0086 0087 //! @return the Color attributes. 0088 Standard_EXPORT Quantity_Color LineColor() const; 0089 0090 //! Sets color of lines for rubber band presentation. 0091 Standard_EXPORT void SetLineColor (const Quantity_Color& theColor); 0092 0093 //! @return the color of rubber band filling. 0094 Standard_EXPORT Quantity_Color FillColor() const; 0095 0096 //! Sets color of rubber band filling. 0097 Standard_EXPORT void SetFillColor (const Quantity_Color& theColor); 0098 0099 //! Sets width of line for rubber band presentation. 0100 Standard_EXPORT void SetLineWidth (const Standard_Real theWidth) const; 0101 0102 //! @return width of lines. 0103 Standard_EXPORT Standard_Real LineWidth() const; 0104 0105 //! Sets type of line for rubber band presentation. 0106 Standard_EXPORT void SetLineType (const Aspect_TypeOfLine theType); 0107 0108 //! @return type of lines. 0109 Standard_EXPORT Aspect_TypeOfLine LineType() const; 0110 0111 //! Sets fill transparency. 0112 //! @param theValue [in] the transparency value. 1.0 is for transparent background 0113 Standard_EXPORT void SetFillTransparency (const Standard_Real theValue) const; 0114 0115 //! @return fill transparency. 0116 Standard_EXPORT Standard_Real FillTransparency() const; 0117 0118 //! Enable or disable filling of rubber band. 0119 Standard_EXPORT void SetFilling (const Standard_Boolean theIsFilling); 0120 0121 //! Enable filling of rubber band with defined parameters. 0122 //! @param theColor [in] color of filling 0123 //! @param theTransparency [in] transparency of the filling. 0 is for opaque filling. 0124 Standard_EXPORT void SetFilling (const Quantity_Color theColor, const Standard_Real theTransparency); 0125 0126 //! @return true if filling of rubber band is enabled. 0127 Standard_EXPORT Standard_Boolean IsFilling() const; 0128 0129 //! @return true if automatic closing of rubber band is enabled. 0130 Standard_EXPORT Standard_Boolean IsPolygonClosed() const; 0131 0132 //! Automatically create an additional line connecting the first and 0133 //! the last screen points to close the boundary polyline 0134 Standard_EXPORT void SetPolygonClosed(Standard_Boolean theIsPolygonClosed); 0135 0136 protected: 0137 0138 //! Returns true if the interactive object accepts the display mode. 0139 Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE 0140 { 0141 return theMode == 0; 0142 } 0143 0144 //! Computes presentation of rubber band. 0145 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr, 0146 const Handle(Prs3d_Presentation)& thePrs, 0147 const Standard_Integer theMode) Standard_OVERRIDE; 0148 0149 //! Does not fill selection primitives for rubber band. 0150 virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/, 0151 const Standard_Integer /*aMode*/) Standard_OVERRIDE { }; 0152 0153 //! Fills triangles primitive array for rubber band filling. 0154 //! It uses Delaunay triangulation. 0155 //! @return true if array of triangles is successfully filled. 0156 Standard_EXPORT Standard_Boolean fillTriangles(); 0157 0158 protected: 0159 0160 NCollection_Sequence<Graphic3d_Vec2i> myPoints; //!< Array of screen points 0161 0162 Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling 0163 Handle(Graphic3d_ArrayOfPolylines) myBorders; //!< Polylines for rubber band borders 0164 0165 Standard_Boolean myIsPolygonClosed; //!< automatic closing of rubber-band flag 0166 }; 0167 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |