//purpose :
//=======================================================================
AIS_RubberBand::AIS_RubberBand()
+: myIsPolygonClosed(Standard_True)
{
myDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
//=======================================================================
AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
const Aspect_TypeOfLine theLineType,
- const Standard_Real theWidth)
+ const Standard_Real theWidth,
+ const Standard_Boolean theIsPolygonClosed)
+: myIsPolygonClosed(theIsPolygonClosed)
{
myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theWidth));
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
const Aspect_TypeOfLine theLineType,
const Quantity_Color theFillColor,
const Standard_Real theTransparency,
- const Standard_Real theLineWidth)
+ const Standard_Real theLineWidth,
+ const Standard_Boolean theIsPolygonClosed)
+: myIsPolygonClosed (theIsPolygonClosed)
{
myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theLineWidth));
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
return aStyle != Aspect_IS_EMPTY;
}
+//=======================================================================
+//function : IsPolygonClosed
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_RubberBand::IsPolygonClosed() const
+{
+ return myIsPolygonClosed;
+}
+
+//=======================================================================
+//function : SetPolygonClosed
+//purpose :
+//=======================================================================
+void AIS_RubberBand::SetPolygonClosed(Standard_Boolean theIsPolygonClosed)
+{
+ myIsPolygonClosed = theIsPolygonClosed;
+}
+
//=======================================================================
//function : fillTriangles
//purpose :
}
// Draw frame
- if (myBorders.IsNull() || myBorders->VertexNumber() != myPoints.Length() + 1)
+ if (myBorders.IsNull() || myBorders->VertexNumber() != myPoints.Length() + (myIsPolygonClosed ? 1 : 0))
{
- myBorders = new Graphic3d_ArrayOfPolylines (myPoints.Length() + 1);
+ myBorders = new Graphic3d_ArrayOfPolylines(myPoints.Length() + (myIsPolygonClosed ? 1 : 0));
for (Standard_Integer anIt = 1; anIt <= myPoints.Length(); anIt++)
{
myBorders->AddVertex ((Standard_Real)myPoints.Value (anIt).x(),
(Standard_Real)myPoints.Value (anIt).y(), 0.0);
}
- myBorders->AddVertex ((Standard_Real)myPoints.Value(1).x(),
- (Standard_Real)myPoints.Value(1).y(), 0.0);
+ if (myIsPolygonClosed)
+ {
+ myBorders->AddVertex((Standard_Real)myPoints.Value(1).x(),
+ (Standard_Real)myPoints.Value(1).y(), 0.0);
+ }
}
else
(Standard_ShortReal)myPoints.Value (anIt).y(), 0.0f);
}
- myBorders->SetVertice (myPoints.Length() + 1, (Standard_ShortReal)myPoints.Value(1).x(),
+ if (myIsPolygonClosed)
+ {
+ myBorders->SetVertice(myPoints.Length() + 1, (Standard_ShortReal)myPoints.Value(1).x(),
(Standard_ShortReal)myPoints.Value(1).y(), 0.0f);
+ }
}
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
//! @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);
+ const Standard_Real theLineWidth = 1.0,
+ const Standard_Boolean theIsPolygonClosed = Standard_True);
//! Constructs the rubber band with defined filling and line parameters.
//! @param theLineColor [in] color of rubber band lines
const Aspect_TypeOfLine theType,
const Quantity_Color theFillColor,
const Standard_Real theTransparency = 1.0,
- const Standard_Real theLineWidth = 1.0);
+ const Standard_Real theLineWidth = 1.0,
+ const Standard_Boolean theIsPolygonClosed = Standard_True);
Standard_EXPORT virtual ~AIS_RubberBand();
//! Sets color of rubber band filling.
Standard_EXPORT void SetFillColor (const Quantity_Color& theColor);
- //! Sets wodth of line for rubber band presentation.
+ //! Sets width of line for rubber band presentation.
Standard_EXPORT void SetLineWidth (const Standard_Real theWidth) const;
//! @return width of lines.
//! @return true if filling of rubber band is enabled.
Standard_EXPORT Standard_Boolean IsFilling() const;
+ //! @return true if automatic closing of rubber band is enabled.
+ Standard_EXPORT Standard_Boolean IsPolygonClosed() const;
+
+ //! Automatically create an additional line connecting the first and
+ //! the last screen points to close the boundary polyline
+ Standard_EXPORT void SetPolygonClosed(Standard_Boolean theIsPolygonClosed);
+
protected:
//! Computes presentation of rubber band.
Handle(Graphic3d_ArrayOfTriangles) myTriangles; //!< Triangles for rubber band filling
Handle(Graphic3d_ArrayOfPolylines) myBorders; //!< Polylines for rubber band borders
+
+ Standard_Boolean myIsPolygonClosed; //!< automatic closing of rubber-band flag
};
#endif