-
Notifications
You must be signed in to change notification settings - Fork 2
/
AIS_RubberBand.hxx
executable file
·150 lines (116 loc) · 6.54 KB
/
AIS_RubberBand.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Created on: 2015-11-23
// Created by: Anastasia BORISOVA
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _AIS_RubberBand_HeaderFile
#define _AIS_RubberBand_HeaderFile
#include <AIS_InteractiveObject.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Vec2.hxx>
#include <NCollection_Sequence.hxx>
DEFINE_STANDARD_HANDLE(AIS_RubberBand, AIS_InteractiveObject)
//! Presentation for drawing rubber band selection.
//! It supports rectangle and polygonal selection.
//! It is constructed in 2d overlay.
//! Default configaration is built without filling.
//! For rectangle selection use SetRectangle() method.
//! For polygonal selection use AddPoint() and GetPoints() methods.
class AIS_RubberBand : public AIS_InteractiveObject
{
public:
DEFINE_STANDARD_RTTIEXT(AIS_RubberBand, AIS_InteractiveObject)
//! Constructs rubber band with default configuration: empty filling and white solid lines.
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
Standard_EXPORT AIS_RubberBand();
//! Consructs the rubber band with empty filling and defined line style.
//! @param theLineColor [in] color of rubber band lines
//! @param theType [in] type of rubber band lines
//! @param theLineWidth [in] width of rubber band line. By default it is 1.
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
Standard_EXPORT AIS_RubberBand (const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theType,
const Standard_Real theLineWidth = 1.0);
//! Constructs the rubber band with defined filling and line parameters.
//! @param theLineColor [in] color of rubber band lines
//! @param theType [in] type of rubber band lines
//! @param theFillColor [in] color of rubber band filling
//! @param theTransparency [in] transparency of the filling. 0 is for opaque filling. By default it is transparent.
//! @param theLineWidth [in] width of rubber band line. By default it is 1.
//! @warning It binds this object with Graphic3d_ZLayerId_TopOSD layer.
Standard_EXPORT AIS_RubberBand (const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theType,
const Quantity_Color theFillColor,
const Standard_Real theTransparency = 1.0,
const Standard_Real theLineWidth = 1.0);
Standard_EXPORT virtual ~AIS_RubberBand();
//! Sets rectangle bounds.
Standard_EXPORT void SetRectangle (const Standard_Integer theMinX, const Standard_Integer theMinY,
const Standard_Integer theMaxX, const Standard_Integer theMaxY);
//! Adds last point to the list of points. They are used to build polygon for rubber band.
//! @sa RemoveLastPoint(), GetPoints()
Standard_EXPORT void AddPoint (const Graphic3d_Vec2i& thePoint);
//! Remove last point from the list of points for the rubber band polygon.
//! @sa AddPoint(), GetPoints()
Standard_EXPORT void RemoveLastPoint();
//! @return points for the rubber band polygon.
Standard_EXPORT const NCollection_Sequence<Graphic3d_Vec2i>& Points() const;
//! Remove all points for the rubber band polygon.
void ClearPoints() { myPoints.Clear(); }
//! @return the Color attributes.
Standard_EXPORT Quantity_Color LineColor() const;
//! Sets color of lines for rubber band presentation.
Standard_EXPORT void SetLineColor (const Quantity_Color& theColor);
//! @return the color of rubber band filling.
Standard_EXPORT Quantity_Color FillColor() const;
//! Sets color of rubber band filling.
Standard_EXPORT void SetFillColor (const Quantity_Color& theColor);
//! Sets wodth of line for rubber band presentation.
Standard_EXPORT void SetLineWidth (const Standard_Real theWidth) const;
//! @return width of lines.
Standard_EXPORT Standard_Real LineWidth() const;
//! Sets type of line for rubber band presentation.
Standard_EXPORT void SetLineType (const Aspect_TypeOfLine theType);
//! @return type of lines.
Standard_EXPORT Aspect_TypeOfLine LineType() const;
//! Sets fill transparency.
//! @param theValue [in] the transparency value. 1.0 is for transparent background
Standard_EXPORT void SetFillTransparency (const Standard_Real theValue) const;
//! @return fill transparency.
Standard_EXPORT Standard_Real FillTransparency() const;
//! Enable or disable filling of rubber band.
Standard_EXPORT void SetFilling (const Standard_Boolean theIsFilling);
//! Enable filling of rubber band with defined parameters.
//! @param theColor [in] color of filling
//! @param theTransparency [in] transparency of the filling. 0 is for opaque filling.
Standard_EXPORT void SetFilling (const Quantity_Color theColor, const Standard_Real theTransparency);
//! @return true if filling of rubber band is enabled.
Standard_EXPORT Standard_Boolean IsFilling() const;
protected:
//! Computes presentation of rubber band.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Does not fill selection primitives for rubber band.
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
const Standard_Integer /*aMode*/) Standard_OVERRIDE { };
//! Fills triangles primitive array for rubber band filling.
//! It uses Delaunay triangulation.
//! @return true if array of triangles is successfully filled.
Standard_EXPORT Standard_Boolean fillTriangles();
protected:
NCollection_Sequence<Graphic3d_Vec2i> myPoints; //!< Array of screen points
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling
Handle(Graphic3d_ArrayOfPolylines) myBorders; //!< Polylines for rubber band borders
};
#endif