- method Add for symmetric chamfer now takes only 2 arguments: distance and edge;
- method GetDistAngle now takes only 3 arguments: index of contour, distance and angle.
+@subsection upgrade_740_aspects Aspects unification
+
+Fill Area, Line and Marker aspects (classes *Graphic3d_AspectFillArea3d*, *Graphic3d_AspectLine3d*, *Graphic3d_AspectMarker3d* and *Graphic3d_AspectText3d*)
+have been merged into new class *Graphic3d_Aspects* providing a single state for rendering primitives of any type.
+The old per-primitive type aspect classes have been preserved as sub-classes of *Graphic3d_Aspects* with default values close to the previous behavior.
+All aspects except Graphic3d_AspectFillArea3d define Graphic3d_TOSM_UNLIT shading model.
+
+The previous approach with dedicated aspects per primitive type was handy in simplified case, but lead to confusion otherwise.
+In fact, drawing points or lines with lighting applied is a valid use case, but only *Graphic3d_AspectFillArea3d* previously defined necessary material properties.
+
+As aspects for different primitive types have been merged, Graphic3d_Group does no more provide per-type aspect properties.
+Existing code relying on old behavior and putting interleaved per-type aspects into single Graphic3d_Group should be updated.
+For example, the following pseudo-code will not work anymore, because all *SetGroupPrimitivesAspect* calls will setup the same property:
+~~~~
+Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
+aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< overrides previous aspect
+
+Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments (2);
+Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (3);
+aGroup->AddPrimitiveArray (aLines); //!< both arrays will use the same aspect
+aGroup->AddPrimitiveArray (aTris);
+~~~~
+
+To solve the problem, the code should be modified to either put primitives into dedicated groups (preferred approach), or using *SetPrimitivesAspect* in proper order:
+~~~~
+Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+
+aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
+Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles (3);
+aGroup->AddPrimitiveArray (aTris);
+
+Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments (2);
+aGroup->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< next array will use the new aspect
+aGroup->AddPrimitiveArray (aLines);
+~~~~
+
@subsection upgrade_740_interiorstyles Interior styles
* *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore.
return;
}
- Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
switch (theMode)
{
case AIS_Shaded:
{
+ Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myTriangles);
}
Standard_FALLTHROUGH
case AIS_WireFrame:
{
+ Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders);
break;
void AIS_ColoredShape::SetColor (const Quantity_Color& theColor)
{
- setColor (myDrawer, theColor);
- myDrawer->SetColor (theColor);
- hasOwnColor = Standard_True;
- LoadRecomputable (AIS_WireFrame);
- LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
aDrawer->FaceBoundaryAspect()->SetColor (theColor);
}
}
+ AIS_Shape::SetColor (theColor);
}
//=======================================================================
void AIS_ColoredShape::SetWidth (const Standard_Real theLineWidth)
{
- setWidth (myDrawer, theLineWidth);
- myOwnWidth = theLineWidth;
- LoadRecomputable (AIS_WireFrame);
- LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
aDrawer->FaceBoundaryAspect()->SetWidth (theLineWidth);
}
}
+ AIS_Shape::SetWidth (theLineWidth);
+}
+
+//=======================================================================
+//function : UnsetWidth
+//purpose :
+//=======================================================================
+void AIS_ColoredShape::UnsetWidth()
+{
+ SetWidth (1.0f);
}
//=======================================================================
void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
{
- setTransparency (myDrawer, theValue);
- myDrawer->SetTransparency ((Standard_ShortReal )theValue);
- LoadRecomputable (AIS_WireFrame);
- LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
aDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
}
}
+ AIS_Shape::SetTransparency (theValue);
}
//=======================================================================
//=======================================================================
void AIS_ColoredShape::UnsetTransparency()
{
- myDrawer->SetTransparency (0.0f);
- if (myDrawer->HasOwnShadingAspect())
- {
- myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
- if (!HasColor()
- && !HasMaterial()
- && !myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
- {
- myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
- }
- }
-
- for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
- {
- const Handle(Prs3d_Drawer)& aDrawer = anIter.Value();
- if (aDrawer->HasOwnShadingAspect())
- {
- aDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
- }
- }
- SynchronizeAspects();
+ SetTransparency (0.0f);
}
//=======================================================================
void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
- setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
- //myOwnMaterial = theMaterial;
- hasOwnMaterial = Standard_True;
- LoadRecomputable (AIS_Shaded);
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
}
}
+ AIS_Shape::SetMaterial (theMaterial);
}
//=======================================================================
//! Sets transparency value.
Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
+ //! Sets the material aspect.
+ Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
+
+public:
+
//! Removes the setting for transparency in the reconstructed compound shape.
Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
- //! Sets the material aspect.
- Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
+ //! Setup line width of entire shape.
+ Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
protected: //! @name override presentation computation
const TCollection_ExtendedString& theText,
const Standard_Integer theLabelPosition)
{
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
if (myDrawer->DimensionAspect()->IsText3d())
{
// getting font parameters
aCenterOfLabel.Transform (aTextPlaneTrsf);
gp_Ax2 aFlippingAxes (aCenterOfLabel, GetPlane().Axis().Direction(), aTextDir);
- Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_True, aFlippingAxes);
+ aGroup->SetFlippingOptions (Standard_True, aFlippingAxes);
// draw text
if (myDrawer->DimensionAspect()->IsTextShaded())
{
myDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (aColor, Aspect_TOL_SOLID, 1.0));
}
-
myDrawer->FreeBoundaryAspect()->Aspect()->SetColor (aColor);
// drawing text
- StdPrs_WFShape::Add (thePresentation, aTextShape, myDrawer);
+ if (Handle(Graphic3d_ArrayOfPrimitives) anEdges = StdPrs_WFShape::AddAllEdges (aTextShape, myDrawer))
+ {
+ aGroup->SetGroupPrimitivesAspect (myDrawer->FreeBoundaryAspect()->Aspect());
+ aGroup->AddPrimitiveArray (anEdges);
+ }
}
Prs3d_Root::CurrentGroup (thePresentation)->SetFlippingOptions (Standard_False, gp_Ax2());
// generate primitives for 2D text
myDrawer->DimensionAspect()->TextAspect()->Aspect()->SetDisplayType (Aspect_TODT_DIMENSION);
- Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePresentation),
+ Prs3d_Text::Draw (aGroup,
myDrawer->DimensionAspect()->TextAspect(),
theText,
theTextPos);
gp_Pnt aTextPos = ElCLib::Value (theExtensionSize, anExtensionLine);
gp_Dir aTextDir = theExtensionDir;
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
drawText (thePresentation,
aTextPos,
aTextDir,
aSensitiveCurve.Append (anExtStart);
aSensitiveCurve.Append (anExtEnd);
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
{
- Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
+ aGroup->SetStencilTestOptions (Standard_True);
}
Handle(Graphic3d_AspectLine3d) aDimensionLineStyle = myDrawer->DimensionAspect()->LineAspect()->Aspect();
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionLineStyle);
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (anExtPrimitive);
+ aGroup->SetPrimitivesAspect (aDimensionLineStyle);
+ aGroup->AddPrimitiveArray (anExtPrimitive);
if (!myDrawer->DimensionAspect()->IsText3d() && theMode == ComputeMode_All)
{
- Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False);
+ aGroup->SetStencilTestOptions (Standard_False);
}
}
case LabelPosition_HCenter:
{
// add label on dimension or extension line to presentation
- Prs3d_Root::NewGroup (thePresentation);
-
gp_Pnt aTextPos = IsTextPositionCustom() ? myFixedTextPosition
: (aCenterLineBegin.XYZ() + aCenterLineEnd.XYZ()) * 0.5;
gp_Dir aTextDir = aDimensionLine.Direction();
// add text primitives
if (theMode == ComputeMode_All || theMode == ComputeMode_Text)
{
+ thePresentation->NewGroup();
drawText (thePresentation,
aTextPos,
aTextDir,
aDimensionAspect->TextAspect()->SetVerticalJustification (aTextJustificaton);
// main dimension line, short extension
- if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
{
- Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_True);
- }
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
- if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
- {
- Prs3d_Root::CurrentGroup (thePresentation)->SetStencilTestOptions (Standard_False);
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
+ {
+ aGroup->SetStencilTestOptions (Standard_True);
+ }
+ aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
+ if (!aDimensionAspect->IsText3d() && theMode == ComputeMode_All)
+ {
+ aGroup->SetStencilTestOptions (Standard_False);
+ }
}
// add arrows to presentation
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
- if (!theIsOneSide)
{
- DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ if (!theIsOneSide)
+ {
+ DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ }
}
if (!isArrowsExternal)
}
// add arrow extension lines to presentation
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aFirstArrowEnd, aFirstExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
- if (!theIsOneSide)
{
DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aSecondArrowEnd, aSecondExtensionDir,
+ aFirstArrowEnd, aFirstExtensionDir,
THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ if (!theIsOneSide)
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aSecondArrowEnd, aSecondExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ }
}
}
-
break;
}
// ------------------------------------------------------------------------ //
case LabelPosition_Left:
{
// add label on dimension or extension line to presentation
- Prs3d_Root::NewGroup (thePresentation);
-
- // Left extension with the text
- DrawExtension (thePresentation, anExtensionSize,
- isArrowsExternal
- ? aFirstArrowEnd
- : aFirstArrowBegin,
- aFirstExtensionDir,
- aLabelString,
- aLabelWidth,
- theMode,
- aLabelPosition);
+ {
+ // Left extension with the text
+ DrawExtension (thePresentation, anExtensionSize,
+ isArrowsExternal
+ ? aFirstArrowEnd
+ : aFirstArrowBegin,
+ aFirstExtensionDir,
+ aLabelString,
+ aLabelWidth,
+ theMode,
+ aLabelPosition);
+ }
// add dimension line primitives
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
{
// add central dimension line
- Prs3d_Root::NewGroup (thePresentation);
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- // add graphical primitives
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
- aPrimSegments->AddVertex (aCenterLineBegin);
- aPrimSegments->AddVertex (aCenterLineEnd);
+ // add graphical primitives
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
+ aPrimSegments->AddVertex (aCenterLineBegin);
+ aPrimSegments->AddVertex (aCenterLineEnd);
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
+ aGroup->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
- // add selection primitives
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
- aSensitiveCurve.Append (aCenterLineBegin);
- aSensitiveCurve.Append (aCenterLineEnd);
+ // add selection primitives
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+ aSensitiveCurve.Append (aCenterLineBegin);
+ aSensitiveCurve.Append (aCenterLineEnd);
+ }
// add arrows to presentation
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
- if (!theIsOneSide)
{
- DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ if (!theIsOneSide)
+ {
+ DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ }
}
if (!isArrowsExternal || theIsOneSide)
}
// add extension lines for external arrows
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aSecondArrowEnd, aSecondExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aSecondArrowEnd, aSecondExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ }
}
break;
case LabelPosition_Right:
{
// add label on dimension or extension line to presentation
- Prs3d_Root::NewGroup (thePresentation);
// Right extension with text
DrawExtension (thePresentation, anExtensionSize,
if (theMode == ComputeMode_All || theMode == ComputeMode_Line)
{
// add central dimension line
- Prs3d_Root::NewGroup (thePresentation);
+ {
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
- // add graphical primitives
- Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
- aPrimSegments->AddVertex (aCenterLineBegin);
- aPrimSegments->AddVertex (aCenterLineEnd);
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
+ // add graphical primitives
+ Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments (2);
+ aPrimSegments->AddVertex (aCenterLineBegin);
+ aPrimSegments->AddVertex (aCenterLineEnd);
+ aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
- // add selection primitives
- SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
- aSensitiveCurve.Append (aCenterLineBegin);
- aSensitiveCurve.Append (aCenterLineEnd);
+ // add selection primitives
+ SelectionGeometry::Curve& aSensitiveCurve = mySelectionGeom.NewCurve();
+ aSensitiveCurve.Append (aCenterLineBegin);
+ aSensitiveCurve.Append (aCenterLineEnd);
+ }
// add arrows to presentation
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
- if (!theIsOneSide)
{
- DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ thePresentation->NewGroup();
+ DrawArrow (thePresentation, aSecondArrowBegin, aSecondArrowDir);
+ if (!theIsOneSide)
+ {
+ DrawArrow (thePresentation, aFirstArrowBegin, aFirstArrowDir);
+ }
}
if (!isArrowsExternal || theIsOneSide)
}
// add extension lines for external arrows
- Prs3d_Root::NewGroup (thePresentation);
-
- DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
- aFirstArrowEnd, aFirstExtensionDir,
- THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ {
+ DrawExtension (thePresentation, aDimensionAspect->ArrowTailSize(),
+ aFirstArrowEnd, aFirstExtensionDir,
+ THE_EMPTY_LABEL, 0.0, theMode, LabelPosition_None);
+ }
}
break;
// add flyout lines to presentation
if (theMode == ComputeMode_All)
{
- Prs3d_Root::NewGroup (thePresentation);
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
Handle(Graphic3d_ArrayOfSegments) aPrimSegments = new Graphic3d_ArrayOfSegments(4);
aPrimSegments->AddVertex (theFirstPoint);
aPrimSegments->AddVertex (theSecondPoint);
aPrimSegments->AddVertex (aLineEndPoint);
- Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
- Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPrimSegments);
+ aGroup->SetGroupPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aPrimSegments);
}
mySelectionGeom.IsComputed = Standard_True;
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->ShadingAspect()->Aspect()->SetPolygonOffsets( aMode, aFactor, aUnits );
-
- // Modify existing presentations
- for (Standard_Integer aPrsIter = 1, n = myPresentations.Length(); aPrsIter <= n; ++aPrsIter)
- {
- const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
- if ( !aPrs3d.IsNull() ) {
- const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
- if( !aStruct.IsNull() ) {
- // Workaround for issue 23115: Need to update also groups, because their
- // face aspect ALWAYS overrides the structure's.
- const Graphic3d_SequenceOfGroup& aGroups = aStruct->Groups();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aGroups); aGroupIter.More(); aGroupIter.Next())
- {
- Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
- if (aGrp.IsNull()
- || !aGrp->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- continue;
- }
-
- Handle(Graphic3d_AspectFillArea3d) aFaceAsp = aGrp->FillAreaAspect();
- aFaceAsp->SetPolygonOffsets(aMode, aFactor, aUnits);
- aGrp->SetGroupPrimitivesAspect(aFaceAsp);
- }
- }
- }
- }
+ SynchronizeAspects();
}
//=======================================================================
}
}
}
+
+//=======================================================================
+//function : replaceAspects
+//purpose :
+//=======================================================================
+void AIS_InteractiveObject::replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
+{
+ if (theMap.IsEmpty())
+ {
+ return;
+ }
+
+ for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
+ {
+ const Handle(PrsMgr_Presentation)& aPrs3d = aPrsIter.ChangeValue().Presentation();
+ if (aPrs3d.IsNull()
+ || aPrs3d->Presentation().IsNull())
+ {
+ continue;
+ }
+
+ for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPrs3d->Presentation()->Groups()); aGroupIter.More(); aGroupIter.Next())
+ {
+ if (!aGroupIter.Value().IsNull())
+ {
+ aGroupIter.ChangeValue()->ReplaceAspects (theMap);
+ }
+ }
+ }
+}
//! so that modifications will take effect on already computed presentation groups (thus avoiding re-displaying the object).
Standard_EXPORT void SynchronizeAspects();
+protected:
+
+ //! Replace aspects of existing (computed) presentation groups,
+ //! so that the new aspects can be applied without recomputing presentation.
+ //! It is NOT recommended approach, because user has to fill such map and then search for each occurrence in computed groups.
+ //! The recommended approach is computing presentation with necessary customized aspects,
+ //! and then modify them directly followed by SynchronizeAspects() call.
+ Standard_EXPORT void replaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap);
+
private:
Standard_EXPORT virtual Standard_Boolean RecomputeEveryPrs() const;
aGroupIter.More(); aGroupIter.Next())
{
Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
- if (!aGrp.IsNull()
- && aGrp->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ if (!aGrp.IsNull())
{
aGrp->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
}
//==================================================
AIS_PointCloud::AIS_PointCloud()
{
- // override default point style to Aspect_TOM_POINT
- myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_YELLOW, 1.0));
+ myDrawer->SetupOwnShadingAspect();
+ myDrawer->ShadingAspect()->Aspect()->SetMarkerType (Aspect_TOM_POINT);
SetDisplayMode (AIS_PointCloud::DM_Points);
SetHilightMode (AIS_PointCloud::DM_BndBox);
{
AIS_InteractiveObject::SetColor(theColor);
- if (!myDrawer->HasOwnPointAspect())
- {
- myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, theColor, 1.0));
- if (myDrawer->HasLink())
- {
- *myDrawer->PointAspect()->Aspect() = *myDrawer->Link()->PointAspect()->Aspect();
- }
- }
- if (!myDrawer->HasOwnShadingAspect())
- {
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- if (myDrawer->HasLink())
- {
- *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
- }
- }
-
- // Override color
myDrawer->ShadingAspect()->SetColor (theColor);
- myDrawer->PointAspect() ->SetColor (theColor);
-
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
- Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
- {
- aGroup->SetGroupPrimitivesAspect (aPointAspect);
- }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAspect);
- }
- }
- }
+ SynchronizeAspects();
}
//=======================================================================
}
AIS_InteractiveObject::UnsetColor();
-
- if (!HasWidth())
- {
- myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
- }
- else
- {
- myDrawer->PointAspect()->SetColor (myDrawer->HasLink()
- ? myDrawer->Link()->PointAspect()->Aspect()->Color()
- : Quantity_Color (Quantity_NOC_YELLOW));
- }
-
- if (HasMaterial()
- || IsTransparent())
{
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
Graphic3d_MaterialAspect aMat = aDefaultMat;
+ Quantity_Color aColor = aDefaultMat.Color();
+ if (myDrawer->HasLink())
+ {
+ aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
+ }
if (HasMaterial() || myDrawer->HasLink())
{
aMat = AIS_GraphicTool::GetMaterial (HasMaterial() ? myDrawer : myDrawer->Link());
}
if (HasMaterial())
{
- Quantity_Color aColor = aDefaultMat.AmbientColor();
- if (myDrawer->HasLink())
- {
- aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
- }
aMat.SetColor (aColor);
}
if (IsTransparent())
aMat.SetTransparency (Standard_ShortReal(aTransp));
}
myDrawer->ShadingAspect()->SetMaterial (aMat, myCurrentFacingModel);
+ myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aColor);
}
- else
- {
- myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
- }
- myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
-
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
- Handle(Graphic3d_AspectMarker3d) aMarkerAsp = myDrawer->Link()->PointAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
- {
- aGroup->SetGroupPrimitivesAspect (aMarkerAsp);
- }
- }
- }
+ SynchronizeAspects();
}
//=======================================================================
//=======================================================================
void AIS_PointCloud::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
- if (!myDrawer->HasOwnShadingAspect())
- {
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- if (myDrawer->HasLink())
- {
- *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
- }
- }
hasOwnMaterial = Standard_True;
myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
}
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
-
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
- }
+ SynchronizeAspects();
}
//=======================================================================
return;
}
- if (HasColor()
- || IsTransparent())
{
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
myDrawer->ShadingAspect()->SetMaterial (myDrawer->HasLink() ?
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
}
}
- else
- {
- myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
- }
hasOwnMaterial = Standard_False;
-
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_PointCloud::DM_Points)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
- }
+ SynchronizeAspects();
}
//=======================================================================
return;
}
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
- aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
+ Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (aPoints);
break;
#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
#include <gp_Circ.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
pa->SetTypeOfMarker(aProjTOM);
}
- // calcul du projete
- StdPrs_Point::Add(aPrs, new Geom_CartesianPoint(ProjPoint), myDrawer);
+ {
+ Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
+ anArrayOfPoints->AddVertex (ProjPoint);
+ aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
+ aGroup->AddPrimitiveArray (anArrayOfPoints);
+ }
if (!myDrawer->HasOwnWireAspect()){
myDrawer->SetWireAspect(new Prs3d_LineAspect(aColor,aCallTOL,2.));}
}
// Si les points ne sont pas confondus...
- if (!ProjPoint.IsEqual (BRep_Tool::Pnt(aVertex),Precision::Confusion())) {
- // calcul des lignes de rappel
- BRepBuilderAPI_MakeEdge MakEd (ProjPoint,BRep_Tool::Pnt(aVertex));
- StdPrs_WFShape::Add (aPrs, MakEd.Edge(), myDrawer);
+ if (!ProjPoint.IsEqual (BRep_Tool::Pnt(aVertex),Precision::Confusion()))
+ {
+ Handle(Graphic3d_Group) aGroup = aPrs->NewGroup();
+ Handle(Graphic3d_ArrayOfSegments) anArrayOfLines = new Graphic3d_ArrayOfSegments (2);
+ anArrayOfLines->AddVertex (ProjPoint);
+ anArrayOfLines->AddVertex (BRep_Tool::Pnt(aVertex));
+ aGroup->SetGroupPrimitivesAspect (myDrawer->WireAspect()->Aspect());
+ aGroup->AddPrimitiveArray (anArrayOfLines);
}
}
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer /*theMode*/)
{
- Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
-
// Draw filling
if (IsFilling() && fillTriangles())
{
- aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
- aGroup->AddPrimitiveArray (myTriangles);
+ Handle(Graphic3d_Group) aGroup1 = thePresentation->NewGroup();
+ aGroup1->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
+ aGroup1->AddPrimitiveArray (myTriangles);
}
// Draw frame
}
}
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
aGroup->AddPrimitiveArray (myBorders);
}
return Standard_False;
}
+// Auxiliary macros
+#define replaceAspectWithDef(theMap, theAspect) \
+ if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
+ { \
+ theMap.Bind (myDrawer->theAspect()->Aspect(), myDrawer->Link()->theAspect()->Aspect()); \
+ }
+
+// Auxiliary macros for replaceWithNewOwnAspects()
+#define replaceAspectWithOwn(theMap, theAspect) \
+ if (myDrawer->Link()->theAspect()->Aspect() != myDrawer->theAspect()->Aspect()) \
+ { \
+ theMap.Bind (myDrawer->Link()->theAspect()->Aspect(), myDrawer->theAspect()->Aspect()); \
+ }
+
+//=======================================================================
+//function : replaceWithNewOwnAspects
+//purpose :
+//=======================================================================
+void AIS_Shape::replaceWithNewOwnAspects()
+{
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+
+ replaceAspectWithOwn (aReplaceMap, ShadingAspect);
+ replaceAspectWithOwn (aReplaceMap, LineAspect);
+ replaceAspectWithOwn (aReplaceMap, WireAspect);
+ replaceAspectWithOwn (aReplaceMap, FreeBoundaryAspect);
+ replaceAspectWithOwn (aReplaceMap, UnFreeBoundaryAspect);
+ replaceAspectWithOwn (aReplaceMap, SeenLineAspect);
+ replaceAspectWithOwn (aReplaceMap, FaceBoundaryAspect);
+ replaceAspectWithOwn (aReplaceMap, PointAspect);
+
+ replaceAspects (aReplaceMap);
+}
+
//==================================================
// Function: AIS_Shape
// Purpose :
bool toRecompute = false;
toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
-
- if (theDrawer->SetupOwnPointAspect())
- {
- toRecompute = true;
- }
+ toRecompute = theDrawer->SetupOwnPointAspect() || toRecompute;
// override color
theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
const bool toRecompute = setColor (myDrawer, theColor);
myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
- if (!toRecompute)
+
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
+ if (!toRecompute
+ || !myDrawer->HasLink())
{
- myToRecomputeModes.Clear();
- myRecomputeEveryPrs = false;
SynchronizeAspects();
- return;
}
-
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
- Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
- Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ else
{
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_Shaded)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
-
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAspect);
- }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
- {
- aGroup->SetGroupPrimitivesAspect (aLineAspect);
- }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
- {
- aGroup->SetGroupPrimitivesAspect (aPointAspect);
- }
- }
+ replaceWithNewOwnAspects();
}
-
- LoadRecomputable (AIS_WireFrame);
- LoadRecomputable (2);
+ recomputeComputed();
}
//=======================================================================
void AIS_Shape::UnsetColor()
{
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
if (!HasColor())
{
- myToRecomputeModes.Clear();
- myRecomputeEveryPrs = false;
return;
}
hasOwnColor = Standard_False;
myDrawer->SetColor (myDrawer->HasLink() ? myDrawer->Link()->Color() : Quantity_Color (Quantity_NOC_WHITE));
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
if (!HasWidth())
{
- Handle(Prs3d_LineAspect) anEmptyAsp;
- myDrawer->SetLineAspect (anEmptyAsp);
- myDrawer->SetWireAspect (anEmptyAsp);
- myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
- myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
- myDrawer->SetSeenLineAspect (anEmptyAsp);
- myDrawer->SetFaceBoundaryAspect (anEmptyAsp);
+ replaceAspectWithDef (aReplaceMap, LineAspect);
+ replaceAspectWithDef (aReplaceMap, WireAspect);
+ replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, SeenLineAspect);
+ replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
+ myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
+ myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
}
else
{
}
else
{
+ replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
- myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
- myRecomputeEveryPrs = true;
+ if (myDrawer->HasOwnPointAspect())
+ {
+ replaceAspectWithDef (aReplaceMap, PointAspect);
+ myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
+ }
+ replaceAspects (aReplaceMap);
+ SynchronizeAspects();
+ recomputeComputed();
}
//=======================================================================
void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
{
myOwnWidth = theLineWidth;
- if (setWidth (myDrawer, theLineWidth))
+
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
+ if (!setWidth (myDrawer, theLineWidth)
+ || !myDrawer->HasLink())
{
- myRecomputeEveryPrs = true;
+ SynchronizeAspects();
}
else
{
- myRecomputeEveryPrs = false;
- myToRecomputeModes.Clear();
- SynchronizeAspects();
+ replaceWithNewOwnAspects();
}
+ recomputeComputed();
}
//=======================================================================
void AIS_Shape::UnsetWidth()
{
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
if (myOwnWidth == 0.0)
{
- myToRecomputeModes.Clear();
- myRecomputeEveryPrs = false;
return;
}
myOwnWidth = 0.0;
if (!HasColor())
{
- const Handle(Prs3d_LineAspect) anEmptyAsp;
- myDrawer->SetLineAspect (anEmptyAsp);
- myDrawer->SetWireAspect (anEmptyAsp);
- myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
- myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
- myDrawer->SetSeenLineAspect (anEmptyAsp);
- myDrawer->SetFaceBoundaryAspect (anEmptyAsp);
- myRecomputeEveryPrs = true;
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+ replaceAspectWithDef (aReplaceMap, LineAspect);
+ replaceAspectWithDef (aReplaceMap, WireAspect);
+ replaceAspectWithDef (aReplaceMap, FreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, UnFreeBoundaryAspect);
+ replaceAspectWithDef (aReplaceMap, SeenLineAspect);
+ replaceAspectWithDef (aReplaceMap, FaceBoundaryAspect);
+ myDrawer->SetLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetWireAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFreeBoundaryAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetUnFreeBoundaryAspect(Handle(Prs3d_LineAspect)());
+ myDrawer->SetSeenLineAspect (Handle(Prs3d_LineAspect)());
+ myDrawer->SetFaceBoundaryAspect (Handle(Prs3d_LineAspect)());
+ replaceAspects (aReplaceMap);
}
else
{
myDrawer->FaceBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_FaceBoundary) : 1.);
SynchronizeAspects();
- myToRecomputeModes.Clear();
- myRecomputeEveryPrs = false;
}
+ recomputeComputed();
}
//=======================================================================
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
+ const bool toRecompute = !myDrawer->HasOwnShadingAspect();
setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
+ if (!toRecompute
+ || !myDrawer->HasLink())
{
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_Shaded)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
-
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
+ SynchronizeAspects();
+ }
+ else
+ {
+ replaceWithNewOwnAspects();
}
-
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
void AIS_Shape::UnsetMaterial()
{
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
if (!HasMaterial())
{
return;
myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
}
+ SynchronizeAspects();
}
else
{
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+ replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
+ replaceAspects (aReplaceMap);
}
- hasOwnMaterial = Standard_False;
-
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_Shaded)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
- }
-
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
void AIS_Shape::SetTransparency (const Standard_Real theValue)
{
+ const bool toRecompute = !myDrawer->HasOwnShadingAspect();
setTransparency (myDrawer, theValue);
myDrawer->SetTransparency ((Standard_ShortReal )theValue);
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
+ if (!toRecompute
+ || !myDrawer->HasLink())
{
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_Shaded)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
+ SynchronizeAspects();
+ }
+ else
+ {
+ replaceWithNewOwnAspects();
}
-
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
void AIS_Shape::UnsetTransparency()
{
+ myRecomputeEveryPrs = false; // no mode to recalculate, only viewer update
+ myToRecomputeModes.Clear();
+
myDrawer->SetTransparency (0.0f);
if (!myDrawer->HasOwnShadingAspect())
{
|| myDrawer->ShadingAspect()->Aspect()->ToMapTexture())
{
myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
+ SynchronizeAspects();
}
else
{
+ Graphic3d_MapOfAspectsToAspects aReplaceMap;
+ replaceAspectWithDef (aReplaceMap, ShadingAspect);
myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
+ replaceAspects (aReplaceMap);
}
-
- // modify shading presentation without re-computation
- const PrsMgr_Presentations& aPrsList = Presentations();
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
- for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
- if (aPrsModed.Mode() != AIS_Shaded)
- {
- continue;
- }
-
- const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
- {
- const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- }
- }
-
- myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
+ //! Replace aspects of already computed groups from drawer link by the new own value.
+ Standard_EXPORT void replaceWithNewOwnAspects();
+
public:
//! Compute HLR presentation for specified shape.
void AIS_TexturedShape::UnsetColor()
{
AIS_Shape::UnsetColor();
-
- for (Standard_Integer aPrsIt = 1; aPrsIt <= Presentations().Length(); ++aPrsIt)
- {
- const PrsMgr_ModedPresentation& aPrsModed = Presentations().Value (aPrsIt);
-
- if (aPrsModed.Mode() != 3)
- continue;
-
- Handle(Prs3d_Presentation) aPrs = aPrsModed.Presentation()->Presentation();
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPrs);
-
- Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
- Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
- Quantity_Color aColor;
- AIS_GraphicTool::GetInteriorColor (myDrawer->Link(), aColor);
- anAreaAsp->SetInteriorColor (aColor);
- // Check if aspect of given type is set for the group,
- // because setting aspect for group with no already set aspect
- // can lead to loss of presentation data
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
- {
- aGroup->SetGroupPrimitivesAspect (aLineAsp);
- }
-
- updateAttributes (aPrs);
- }
}
//=======================================================================
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (thePrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (!aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- continue;
- }
aGroup->SetGroupPrimitivesAspect (myAspect);
}
}
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
- if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
- {
- aGroup->SetGroupPrimitivesAspect (anAreaAsp);
- }
+ aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
const DsgPrs_ArrowSide ArrowSide,
const Standard_Boolean drawFromCenter)
{
- Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
+ Handle(Graphic3d_Group) aGroup = aPresentation->NewGroup();
Quantity_Color aColor = LA->LineAspect()->Aspect()->Color();
Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0);
- Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp);
- Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
+ aGroup->SetGroupPrimitivesAspect (LA->LineAspect()->Aspect());
switch(ArrowSide) {
case DsgPrs_AS_NONE:
}
case DsgPrs_AS_FIRSTAR:
{
- Prs3d_Arrow::Draw(Prs3d_Root::CurrentGroup (aPresentation),
+ Prs3d_Arrow::Draw (aGroup,
pt1,
dir1,
LA->ArrowAspect()->Angle(),
case DsgPrs_AS_LASTAR:
{
- Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
+ Prs3d_Arrow::Draw (aGroup,
pt2,
dir2,
LA->ArrowAspect()->Angle(),
case DsgPrs_AS_BOTHAR:
{
- Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
+ Prs3d_Arrow::Draw (aGroup,
pt1,
dir1,
LA->ArrowAspect()->Angle(),
LA->ArrowAspect()->Length());
- Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
+ Prs3d_Arrow::Draw (aGroup,
pt2,
dir2,
LA->ArrowAspect()->Angle(),
{
if(drawFromCenter)
{
- Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1);
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (2);
anArrayOfPoints1->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints1);
- }
- if(drawFromCenter)
- {
- Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1);
- anArrayOfPoints2->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2);
+ anArrayOfPoints1->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
+ aGroup->SetGroupPrimitivesAspect (aMarkerAsp);
+ aGroup->AddPrimitiveArray (anArrayOfPoints1);
}
break;
}
case DsgPrs_AS_FIRSTAR_LASTPT:
{
// an Arrow
- Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
+ Prs3d_Arrow::Draw (aGroup,
pt1,
dir1,
LA->ArrowAspect()->Angle(),
// a Round
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
+ aGroup->SetPrimitivesAspect (aMarkerAsp);
+ aGroup->AddPrimitiveArray (anArrayOfPoints);
break;
}
case DsgPrs_AS_FIRSTPT_LASTAR:
{
- // a Round
- if(drawFromCenter)
- {
- Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
- anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
- Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
- }
// an Arrow
- Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation),
+ Prs3d_Arrow::Draw (aGroup,
pt2,
dir2,
LA->ArrowAspect()->Angle(),
LA->ArrowAspect()->Length());
+
+ // a Round
+ if (drawFromCenter)
+ {
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
+ anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
+ aGroup->SetPrimitivesAspect (aMarkerAsp);
+ aGroup->AddPrimitiveArray (anArrayOfPoints);
+ }
break;
}
}
Graphic3d_ArrayOfTriangleFans.hxx
Graphic3d_ArrayOfTriangles.hxx
Graphic3d_ArrayOfTriangleStrips.hxx
+Graphic3d_Aspects.cxx
+Graphic3d_Aspects.hxx
Graphic3d_AspectFillArea3d.cxx
Graphic3d_AspectFillArea3d.hxx
Graphic3d_AspectLine3d.cxx
Graphic3d_AspectMarker3d.hxx
Graphic3d_AspectText3d.cxx
Graphic3d_AspectText3d.hxx
-Graphic3d_AspectTextDefinitionError.hxx
Graphic3d_AttribBuffer.cxx
Graphic3d_AttribBuffer.hxx
Graphic3d_BndBox3d.hxx
Graphic3d_LevelOfTextureAnisotropy.hxx
Graphic3d_LightSet.cxx
Graphic3d_LightSet.hxx
+Graphic3d_MapOfAspectsToAspects.hxx
Graphic3d_MapIteratorOfMapOfStructure.hxx
Graphic3d_MapOfObject.hxx
Graphic3d_MapOfStructure.hxx
#include <Graphic3d_AspectFillArea3d.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Graphic3d_Aspects)
// =======================================================================
// function : Graphic3d_AspectFillArea3d
// purpose :
// =======================================================================
Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
-: myInteriorColor (Quantity_NOC_CYAN1),
- myBackInteriorColor (Quantity_NOC_CYAN1),
- myEdgeColor (Quantity_NOC_WHITE),
- myInteriorStyle (Aspect_IS_EMPTY),
- myShadingModel (Graphic3d_TOSM_DEFAULT),
- myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
- myAlphaCutoff (0.5f),
- myEdgeType (Aspect_TOL_SOLID),
- myEdgeWidth (1.0f),
- myHatchStyle (Handle(Graphic3d_HatchStyle)()),
- myToSkipFirstEdge (false),
- myToDistinguishMaterials (false),
- myToDrawEdges (false),
- myToDrawSilhouette (false),
- myToSuppressBackFaces (true),
- myToMapTexture (false)
{
- //
+ myInteriorStyle = Aspect_IS_EMPTY;
}
// =======================================================================
const Standard_Real theEdgeLineWidth,
const Graphic3d_MaterialAspect& theFrontMaterial,
const Graphic3d_MaterialAspect& theBackMaterial)
-: myFrontMaterial (theFrontMaterial),
- myBackMaterial (theBackMaterial),
- myInteriorColor (theInteriorColor),
- myBackInteriorColor (theInteriorColor),
- myEdgeColor (theEdgeColor),
- myInteriorStyle (theInteriorStyle),
- myShadingModel (Graphic3d_TOSM_DEFAULT),
- myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
- myAlphaCutoff (0.5f),
- myEdgeType (theEdgeLineType),
- myEdgeWidth ((float )theEdgeLineWidth),
- myHatchStyle (Handle(Graphic3d_HatchStyle)()),
- myToSkipFirstEdge (false),
- myToDistinguishMaterials (false),
- myToDrawEdges (false),
- myToDrawSilhouette (false),
- myToSuppressBackFaces (true),
- myToMapTexture (false)
{
- if (theEdgeLineWidth <= 0.0)
- {
- throw Aspect_AspectFillAreaDefinitionError("Bad value for EdgeLineWidth");
- }
-}
-
-// =======================================================================
-// function : Graphic3d_AspectFillArea3d
-// purpose :
-// =======================================================================
-void Graphic3d_AspectFillArea3d::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture)
-{
- if (theTexture.IsNull())
- {
- myTextureSet.Nullify();
- return;
- }
-
- myTextureSet = new Graphic3d_TextureSet (theTexture);
+ myFrontMaterial = theFrontMaterial;
+ myBackMaterial = theBackMaterial;
+ myInteriorColor.SetRGB (theInteriorColor);
+ myBackInteriorColor.SetRGB (theInteriorColor);
+ myEdgeColor.SetRGB (theEdgeColor);
+ myInteriorStyle = theInteriorStyle;
+ myLineType = theEdgeLineType;
+ SetEdgeWidth ((float )theEdgeLineWidth);
}
#ifndef _Graphic3d_AspectFillArea3d_HeaderFile
#define _Graphic3d_AspectFillArea3d_HeaderFile
-#include <Aspect_AspectFillAreaDefinitionError.hxx>
-#include <Aspect_PolygonOffsetMode.hxx>
-#include <Aspect_InteriorStyle.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_AlphaMode.hxx>
-#include <Graphic3d_HatchStyle.hxx>
-#include <Graphic3d_MaterialAspect.hxx>
-#include <Graphic3d_PolygonOffset.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Graphic3d_TextureMap.hxx>
-#include <Graphic3d_TextureSet.hxx>
-#include <Graphic3d_TypeOfShadingModel.hxx>
-#include <Standard.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_ShortReal.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Type.hxx>
-#include <Quantity_ColorRGBA.hxx>
+#include <Graphic3d_Aspects.hxx>
//! This class defines graphic attributes for opaque 3d primitives (polygons, triangles, quadrilaterals).
-class Graphic3d_AspectFillArea3d : public Standard_Transient
+class Graphic3d_AspectFillArea3d : public Graphic3d_Aspects
{
- DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectFillArea3d, Graphic3d_Aspects)
public:
//! Creates a context table for fill area primitives defined with the following default values:
const Graphic3d_MaterialAspect& theFrontMaterial,
const Graphic3d_MaterialAspect& theBackMaterial);
- //! Return interior rendering style (Aspect_IS_EMPTY by default, which means nothing will be rendered!).
- Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; }
-
- //! Modifies the interior type used for rendering
- void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; }
-
- //! Returns shading model (Graphic3d_TOSM_DEFAULT by default, which means that Shading Model set as default for entire Viewer will be used)
- Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
-
- //! Sets shading model
- void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) { myShadingModel = theShadingModel; }
-
- //! Returns the way how alpha value should be treated (Graphic3d_AlphaMode_BlendAuto by default, for backward compatibility).
- Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
-
- //! Returns alpha cutoff threshold, for discarding fragments within Graphic3d_AlphaMode_Mask mode (0.5 by default).
- //! If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent.
- Standard_ShortReal AlphaCutoff() const { return myAlphaCutoff; }
-
- //! Defines the way how alpha value should be treated.
- void SetAlphaMode (Graphic3d_AlphaMode theMode, Standard_ShortReal theAlphaCutoff = 0.5f)
- {
- myAlphaMode = theMode;
- myAlphaCutoff = theAlphaCutoff;
- }
-
- //! Return interior color.
- const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); }
-
- //! Return interior color.
- const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; }
-
- //! Modifies the color of the interior of the face
- void SetInteriorColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
-
- //! Modifies the color of the interior of the face
- void SetInteriorColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
-
- //! Return back interior color.
- const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); }
-
- //! Return back interior color.
- const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; }
-
- //! Modifies the color of the interior of the back face
- void SetBackInteriorColor (const Quantity_Color& theColor) { myBackInteriorColor.SetRGB (theColor); }
-
- //! Modifies the color of the interior of the back face
- void SetBackInteriorColor (const Quantity_ColorRGBA& theColor) { myBackInteriorColor = theColor; }
-
- //! Returns the surface material of external faces
- const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; }
-
- //! Returns the surface material of external faces
- Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; }
-
- //! Modifies the surface material of external faces
- void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; }
-
- //! Returns the surface material of internal faces
- const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; }
-
- //! Returns the surface material of internal faces
- Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; }
-
- //! Modifies the surface material of internal faces
- void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; }
-
- //! Returns true if back faces should be suppressed (true by default).
- bool ToSuppressBackFaces() const { return myToSuppressBackFaces; }
-
- //! Assign back faces culling flag.
- void SetSuppressBackFaces (bool theToSuppress) { myToSuppressBackFaces = theToSuppress; }
-
- //! Returns true if back faces should be suppressed (true by default).
- bool BackFace() const { return myToSuppressBackFaces; }
-
- //! Allows the display of back-facing filled polygons.
- void AllowBackFace() { myToSuppressBackFaces = false; }
-
- //! Suppress the display of back-facing filled polygons.
- //! A back-facing polygon is defined as a polygon whose
- //! vertices are in a clockwise order with respect to screen coordinates.
- void SuppressBackFace() { myToSuppressBackFaces = true; }
-
- //! Returns true if material properties should be distinguished for back and front faces (false by default).
- bool Distinguish() const { return myToDistinguishMaterials; }
-
- //! Set material distinction between front and back faces.
- void SetDistinguish (bool toDistinguish) { myToDistinguishMaterials = toDistinguish; }
-
- //! Allows material distinction between front and back faces.
- void SetDistinguishOn() { myToDistinguishMaterials = true; }
-
- //! Forbids material distinction between front and back faces.
- void SetDistinguishOff() { myToDistinguishMaterials = false; }
-
- //! Return shader program.
- const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
-
- //! Sets up OpenGL/GLSL shader program.
- void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
-
- //! Return texture array to be mapped.
- const Handle(Graphic3d_TextureSet)& TextureSet() const { return myTextureSet; }
-
- //! Setup texture array to be mapped.
- void SetTextureSet (const Handle(Graphic3d_TextureSet)& theTextures) { myTextureSet = theTextures; }
-
- //! Return texture to be mapped.
- //Standard_DEPRECATED("Deprecated method, TextureSet() should be used instead")
- Handle(Graphic3d_TextureMap) TextureMap() const
- {
- return !myTextureSet.IsNull() && !myTextureSet->IsEmpty()
- ? myTextureSet->First()
- : Handle(Graphic3d_TextureMap)();
- }
-
- //! Assign texture to be mapped.
- //! See also SetTextureMapOn() to actually activate texture mapping.
- //Standard_DEPRECATED("Deprecated method, SetTextureSet() should be used instead")
- Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture);
-
- //! Return true if texture mapping is enabled (false by default).
- bool ToMapTexture() const { return myToMapTexture; }
-
- //! Return true if texture mapping is enabled (false by default).
- bool TextureMapState() const { return myToMapTexture; }
-
- //! Enable or disable texture mapping (has no effect if texture is not set).
- void SetTextureMapOn (bool theToMap) { myToMapTexture = theToMap; }
-
- //! Enable texture mapping (has no effect if texture is not set).
- void SetTextureMapOn() { myToMapTexture = true; }
-
- //! Disable texture mapping.
- void SetTextureMapOff() { myToMapTexture = false; }
-
- //! Returns current polygon offsets settings.
- const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
-
- //! Sets polygon offsets settings.
- void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; }
-
- //! Returns current polygon offsets settings.
- void PolygonOffsets (Standard_Integer& theMode,
- Standard_ShortReal& theFactor,
- Standard_ShortReal& theUnits) const
- {
- theMode = myPolygonOffset.Mode;
- theFactor = myPolygonOffset.Factor;
- theUnits = myPolygonOffset.Units;
- }
-
- //! Sets up OpenGL polygon offsets mechanism.
- //! <aMode> parameter can contain various combinations of
- //! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
- //! that polygon offsets are not changed).
- //! If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
- //! arguments are used by graphic renderer to calculate a depth offset value:
- //!
- //! offset = <aFactor> * m + <aUnits> * r, where
- //! m - maximum depth slope for the polygon currently being displayed,
- //! r - minimum window coordinates depth resolution (implementation-specific)
- //!
- //! Default settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
- //!
- //! Negative offset values move polygons closer to the viewport,
- //! while positive values shift polygons away.
- //! Consult OpenGL reference for details (glPolygonOffset function description).
- void SetPolygonOffsets (const Standard_Integer theMode,
- const Standard_ShortReal theFactor = 1.0f,
- const Standard_ShortReal theUnits = 0.0f)
- {
- myPolygonOffset.Mode = (Aspect_PolygonOffsetMode )(theMode & Aspect_POM_Mask);
- myPolygonOffset.Factor = theFactor;
- myPolygonOffset.Units = theUnits;
- }
-
public:
- //! Returns true if edges should be drawn (false by default).
- bool ToDrawEdges() const { return myToDrawEdges && myEdgeType != Aspect_TOL_EMPTY; }
-
- //! Set if edges should be drawn or not.
- void SetDrawEdges (bool theToDraw)
- {
- myToDrawEdges = theToDraw;
- if (myEdgeType == Aspect_TOL_EMPTY)
- {
- myEdgeType = Aspect_TOL_SOLID;
- }
- }
-
- //! Returns true if edges should be drawn.
+ Standard_DEPRECATED("Deprecated method, ToDrawEdges() should be used instead")
bool Edge() const { return ToDrawEdges(); }
- //! The edges of FillAreas are drawn.
- void SetEdgeOn() { SetDrawEdges (true); }
-
- //! The edges of FillAreas are not drawn.
- void SetEdgeOff() { SetDrawEdges (false); }
-
- //! Return color of edges.
- const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
-
- //! Return color of edges.
- const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; }
-
- //! Modifies the color of the edge of the face
- void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
-
- //! Modifies the color of the edge of the face
- void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
-
- //! Return edges line type.
- Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
-
- //! Modifies the edge line type
- void SetEdgeLineType (const Aspect_TypeOfLine theType) { myEdgeType = theType; }
-
- //! Return width for edges in pixels.
- Standard_ShortReal EdgeWidth() const { return myEdgeWidth; }
-
- //! Modifies the edge thickness
- //! Warning: Raises AspectFillAreaDefinitionError if the width is a negative value.
- void SetEdgeWidth (const Standard_Real theWidth)
- {
- if (theWidth <= 0.0)
- {
- throw Aspect_AspectFillAreaDefinitionError("Bad value for EdgeLineWidth");
- }
- myEdgeWidth = (float )theWidth;
- }
-
- //! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
- //! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
- //! This flag allows rendering wireframe presentation of quad-only array split into triangles.
- //! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
- //! 1------2
- //! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3
- //! 0------3
- bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
-
- //! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
- void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
-
- //! Returns TRUE if silhouette (outline) should be drawn (with edge color and width); FALSE by default.
- bool ToDrawSilhouette() const { return myToDrawSilhouette; }
-
- //! Enables/disables drawing silhouette (outline).
- void SetDrawSilhouette (bool theToDraw) { myToDrawSilhouette = theToDraw; }
-
-public:
-
- //! Returns the hatch type used when InteriorStyle is IS_HATCH
- const Handle(Graphic3d_HatchStyle)& HatchStyle() const { return myHatchStyle; }
-
- //! Modifies the hatch type used when InteriorStyle is IS_HATCH
- void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle) { myHatchStyle = theStyle; }
-
- //! Modifies the hatch type used when InteriorStyle is IS_HATCH
- //! @warning This method always creates a new handle for a given hatch style
- void SetHatchStyle (const Aspect_HatchStyle theStyle)
- {
- if (theStyle == Aspect_HS_SOLID)
- {
- myHatchStyle.Nullify();
- return;
- }
-
- myHatchStyle = new Graphic3d_HatchStyle (theStyle);
- }
-
- //! Returns the current values.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Aspect_InteriorStyle& theStyle,
- Quantity_Color& theIntColor,
- Quantity_Color& theEdgeColor,
- Aspect_TypeOfLine& theType,
- Standard_Real& theWidth) const
- {
- theStyle = myInteriorStyle;
- theIntColor = myInteriorColor.GetRGB();
- theEdgeColor= myEdgeColor.GetRGB();
- theType = myEdgeType;
- theWidth = myEdgeWidth;
- }
-
- //! Returns the current values.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Aspect_InteriorStyle& theStyle,
- Quantity_Color& theIntColor,
- Quantity_Color& theBackIntColor,
- Quantity_Color& theEdgeColor,
- Aspect_TypeOfLine& theType,
- Standard_Real& theWidth) const
- {
- theStyle = myInteriorStyle;
- theIntColor = myInteriorColor.GetRGB();
- theBackIntColor= myBackInteriorColor.GetRGB();
- theEdgeColor = myEdgeColor.GetRGB();
- theType = myEdgeType;
- theWidth = myEdgeWidth;
- }
-
-protected:
-
- Handle(Graphic3d_ShaderProgram) myProgram;
- Handle(Graphic3d_TextureSet) myTextureSet;
- Graphic3d_MaterialAspect myFrontMaterial;
- Graphic3d_MaterialAspect myBackMaterial;
-
- Quantity_ColorRGBA myInteriorColor;
- Quantity_ColorRGBA myBackInteriorColor;
- Quantity_ColorRGBA myEdgeColor;
- Aspect_InteriorStyle myInteriorStyle;
- Graphic3d_TypeOfShadingModel myShadingModel;
- Graphic3d_AlphaMode myAlphaMode;
- Standard_ShortReal myAlphaCutoff;
- Aspect_TypeOfLine myEdgeType;
- Standard_ShortReal myEdgeWidth;
- Handle(Graphic3d_HatchStyle) myHatchStyle;
-
- Graphic3d_PolygonOffset myPolygonOffset;
- bool myToSkipFirstEdge;
- bool myToDistinguishMaterials;
- bool myToDrawEdges;
- bool myToDrawSilhouette;
- bool myToSuppressBackFaces;
- bool myToMapTexture;
-
};
-DEFINE_STANDARD_HANDLE(Graphic3d_AspectFillArea3d, Standard_Transient)
+DEFINE_STANDARD_HANDLE(Graphic3d_AspectFillArea3d, Graphic3d_Aspects)
#endif // _Graphic3d_AspectFillArea3d_HeaderFile
#include <Graphic3d_AspectLine3d.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Graphic3d_Aspects)
// =======================================================================
// function : Graphic3d_AspectLine3d
// purpose :
// =======================================================================
Graphic3d_AspectLine3d::Graphic3d_AspectLine3d()
-: myColor (Quantity_NOC_YELLOW),
- myType (Aspect_TOL_SOLID),
- myWidth (1.0f)
{
- //
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
+ myLineType = Aspect_TOL_SOLID;
+ myLineWidth = 1.0f;
}
// =======================================================================
// function : Graphic3d_AspectLine3d
// purpose :
// =======================================================================
-Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& theColor,
- const Aspect_TypeOfLine theType,
- const Standard_Real theWidth)
-: myColor (theColor),
- myType (theType),
- myWidth ((float )theWidth)
+Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& theColor,
+ Aspect_TypeOfLine theType,
+ Standard_Real theWidth)
{
- if (myWidth <= 0.0f)
- {
- throw Aspect_AspectLineDefinitionError("Graphic3d_AspectLine3d, Bad value for LineWidth");
- }
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myInteriorColor.SetRGB (theColor);
+ myLineType = theType;
+ SetLineWidth ((float)theWidth);
}
#ifndef _Graphic3d_AspectLine3d_HeaderFile
#define _Graphic3d_AspectLine3d_HeaderFile
-#include <Aspect_AspectLineDefinitionError.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Standard.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Type.hxx>
-#include <Quantity_ColorRGBA.hxx>
+#include <Graphic3d_Aspects.hxx>
//! Creates and updates a group of attributes for 3d line primitives.
//! This group contains the color, the type of line, and its thickness.
-class Graphic3d_AspectLine3d : public Standard_Transient
+class Graphic3d_AspectLine3d : public Graphic3d_Aspects
{
- DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectLine3d, Graphic3d_Aspects)
public:
//! Creates a context table for line primitives
//! The nominal line width is 1 pixel.
//! The width of the line is determined by applying the line width scale factor to this nominal line width.
//! The supported line widths vary by 1-pixel units.
- Standard_EXPORT Graphic3d_AspectLine3d (const Quantity_Color& theColor,
- const Aspect_TypeOfLine theType,
- const Standard_Real theWidth);
-
- //! Return color.
- const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
-
- //! Return color.
- const Quantity_Color& Color() const { return myColor.GetRGB(); }
-
- //! Modifies the color.
- void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
+ Standard_EXPORT Graphic3d_AspectLine3d (const Quantity_Color& theColor,
+ Aspect_TypeOfLine theType,
+ Standard_Real theWidth);
//! Return line type.
- Aspect_TypeOfLine Type() const { return myType; }
+ Aspect_TypeOfLine Type() const { return myLineType; }
//! Modifies the type of line.
- void SetType (const Aspect_TypeOfLine theType) { myType = theType; }
+ void SetType (const Aspect_TypeOfLine theType) { myLineType = theType; }
//! Return line width.
- Standard_ShortReal Width() const { return myWidth; }
+ Standard_ShortReal Width() const { return myLineWidth; }
//! Modifies the line thickness.
- //! Warning: Raises AspectLineDefinitionError if the width is a negative value.
+ //! Warning: Raises Standard_OutOfRange if the width is a negative value.
void SetWidth (const Standard_Real theWidth) { SetWidth ((float )theWidth); }
//! Modifies the line thickness.
- //! Warning: Raises AspectLineDefinitionError if the width is a negative value.
- void SetWidth (const Standard_ShortReal theWidth)
- {
- if (theWidth <= 0.0f)
- {
- throw Aspect_AspectLineDefinitionError("Graphic3d_AspectLine3d, Bad value for LineWidth");
- }
- myWidth = theWidth;
- }
-
- //! Return shader program.
- const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
-
- //! Sets up OpenGL/GLSL shader program.
- void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
-
- //! Check for equality with another line aspect.
- bool IsEqual (const Graphic3d_AspectLine3d& theOther)
+ //! Warning: Raises Standard_OutOfRange if the width is a negative value.
+ void SetWidth (Standard_ShortReal theWidth)
{
- if (this == &theOther)
- {
- return true;
- }
-
- return myProgram == theOther.myProgram
- && myType == theOther.myType
- && myColor == theOther.myColor
- && myWidth == theOther.myWidth;
- }
-
-public:
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Aspect_TypeOfLine& theType,
- Standard_Real& theWidth) const
- {
- theColor = myColor.GetRGB();
- theType = myType;
- theWidth = myWidth;
+ SetLineWidth (theWidth);
}
-protected:
-
- Handle(Graphic3d_ShaderProgram) myProgram;
- Quantity_ColorRGBA myColor;
- Aspect_TypeOfLine myType;
- Standard_ShortReal myWidth;
-
};
-DEFINE_STANDARD_HANDLE(Graphic3d_AspectLine3d, Standard_Transient)
+DEFINE_STANDARD_HANDLE(Graphic3d_AspectLine3d, Graphic3d_Aspects)
#endif // _Graphic3d_AspectLine3d_HeaderFile
#include <Graphic3d_AspectMarker3d.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Graphic3d_Aspects)
// =======================================================================
// function : Graphic3d_AspectMarker3d
// purpose :
// =======================================================================
Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d()
-: myColor (Quantity_NOC_YELLOW),
- myType (Aspect_TOM_X),
- myScale (1.0f)
{
- //
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
+ myMarkerType = Aspect_TOM_X;
+ myMarkerScale = 1.0f;
}
// =======================================================================
Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker theType,
const Quantity_Color& theColor,
const Standard_Real theScale)
-: myColor (theColor),
- myType (theType),
- myScale ((float )theScale)
{
- if (theScale <= 0.0)
- {
- throw Aspect_AspectMarkerDefinitionError("Bad value for MarkerScale");
- }
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myInteriorColor.SetRGB (theColor);
+ myMarkerType = theType;
+ SetMarkerScale ((float )theScale);
}
// =======================================================================
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Handle(TColStd_HArray1OfByte)& theTextureBitMap)
-: myMarkerImage (new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight)),
- myColor (theColor),
- myType (Aspect_TOM_USERDEFINED),
- myScale (1.0f)
{
- //
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myMarkerImage = new Graphic3d_MarkerImage(theTextureBitMap, theWidth, theHeight);
+ myInteriorColor.SetRGB (theColor),
+ myMarkerType = Aspect_TOM_USERDEFINED;
+ myMarkerScale = 1.0f;
}
// =======================================================================
// purpose :
// =======================================================================
Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Handle(Image_PixMap)& theTextureImage)
-: myMarkerImage (new Graphic3d_MarkerImage (theTextureImage)),
- myColor (Quantity_NOC_YELLOW),
- myType (Aspect_TOM_USERDEFINED),
- myScale (1.0f)
{
- //
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myMarkerImage = new Graphic3d_MarkerImage (theTextureImage);
+ myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
+ myMarkerType = Aspect_TOM_USERDEFINED;
+ myMarkerScale = 1.0f;
}
// =======================================================================
#ifndef _Graphic3d_AspectMarker3d_HeaderFile
#define _Graphic3d_AspectMarker3d_HeaderFile
-#include <Aspect_AspectMarkerDefinitionError.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <Graphic3d_MarkerImage.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Image_PixMap.hxx>
-#include <Standard.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Type.hxx>
-#include <TColStd_HArray1OfByte.hxx>
-#include <Quantity_ColorRGBA.hxx>
+#include <Graphic3d_Aspects.hxx>
//! Creates and updates an attribute group for marker type primitives.
//! This group contains the type of marker, its color, and its scale factor.
-class Graphic3d_AspectMarker3d : public Standard_Transient
+class Graphic3d_AspectMarker3d : public Graphic3d_Aspects
{
- DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Graphic3d_Aspects)
public:
//! Creates a context table for marker primitives
//! defined with the specified values.
Standard_EXPORT Graphic3d_AspectMarker3d(const Handle(Image_PixMap)& theTextureImage);
- //! Return color.
- const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
-
- //! Return the color.
- const Quantity_Color& Color() const { return myColor.GetRGB(); }
-
- //! Modifies the color.
- void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
-
//! Return scale factor.
- Standard_ShortReal Scale() const { return myScale; }
+ Standard_ShortReal Scale() const { return myMarkerScale; }
//! Modifies the scale factor.
//! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor.
//! It is always the smallest displayable dot.
- //! Warning: Raises AspectMarkerDefinitionError if the scale is a negative value.
+ //! Warning: Raises Standard_OutOfRange if the scale is a negative value.
void SetScale (const Standard_ShortReal theScale)
{
- if (theScale <= 0.0f)
- {
- throw Aspect_AspectMarkerDefinitionError("Bad value for MarkerScale");
- }
- myScale = theScale;
+ SetMarkerScale (theScale);
}
//! Assign scale factor.
void SetScale (const Standard_Real theScale) { SetScale ((float )theScale); }
//! Return marker type.
- Aspect_TypeOfMarker Type() const { return myType; }
+ Aspect_TypeOfMarker Type() const { return myMarkerType; }
//! Modifies the type of marker.
- void SetType (const Aspect_TypeOfMarker theType) { myType = theType; }
+ void SetType (const Aspect_TypeOfMarker theType) { myMarkerType = theType; }
//! Returns marker's texture size.
Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
//! Could be null handle if marker aspect has been initialized as default type of marker.
const Handle(Graphic3d_MarkerImage)& GetMarkerImage() const { return myMarkerImage; }
- //! Set marker's image texture.
- void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
-
Standard_EXPORT void SetBitMap (const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTexture);
- //! Return the program.
- const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
-
- //! Sets up OpenGL/GLSL shader program.
- void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
-
-public:
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Aspect_TypeOfMarker& theType,
- Standard_Real& theScale) const
- {
- theColor = myColor.GetRGB();
- theType = myType;
- theScale = myScale;
- }
-
-protected:
-
- Handle(Graphic3d_ShaderProgram) myProgram;
- Handle(Graphic3d_MarkerImage) myMarkerImage;
- Quantity_ColorRGBA myColor;
- Aspect_TypeOfMarker myType;
- Standard_ShortReal myScale;
-
};
-DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Standard_Transient)
+DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Graphic3d_Aspects)
#endif // _Graphic3d_AspectMarker3d_HeaderFile
#include <Graphic3d_AspectText3d.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient)
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Graphic3d_Aspects)
// =======================================================================
// function : Graphic3d_AspectText3d
// purpose :
// =======================================================================
Graphic3d_AspectText3d::Graphic3d_AspectText3d()
-: myFont (Font_NOF_ASCII_MONO),
- myColor (Quantity_NOC_YELLOW),
- myFactor (1.0),
- mySpace (0.0),
- myStyle (Aspect_TOST_NORMAL),
- myDisplayType (Aspect_TODT_NORMAL),
- myColorSubTitle (Quantity_NOC_WHITE),
- myTextZoomable (false),
- myTextAngle (0.0),
- myTextFontAspect(Font_FA_Regular)
{
- //
+ // actually this should be a special state Graphic3d_AlphaMode_MaskBlend
+ // since text is drawn in usual order with normal opaque objects (thanks to alpha test),
+ // but blending is also enabled to smoothen boundaries
+ SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myInteriorColor.SetRGB (Quantity_NOC_YELLOW);
+ myEdgeColor.SetRGB (Quantity_NOC_WHITE);
}
// =======================================================================
// function : Graphic3d_AspectText3d
// purpose :
// =======================================================================
-Graphic3d_AspectText3d::Graphic3d_AspectText3d (const Quantity_Color& theColor,
- const Standard_CString theFont,
- const Standard_Real theExpansionFactor,
- const Standard_Real theSpace,
- const Aspect_TypeOfStyleText theStyle,
- const Aspect_TypeOfDisplayText theDisplayType)
-: myFont (theFont),
- myColor (theColor),
- myFactor (theExpansionFactor),
- mySpace (theSpace),
- myStyle (theStyle),
- myDisplayType (theDisplayType),
- myColorSubTitle (Quantity_NOC_WHITE),
- myTextZoomable (false),
- myTextAngle (0.0),
- myTextFontAspect(Font_FA_Regular)
+Graphic3d_AspectText3d::Graphic3d_AspectText3d (const Quantity_Color& theColor,
+ Standard_CString theFont,
+ Standard_Real ,
+ Standard_Real ,
+ Aspect_TypeOfStyleText theStyle,
+ Aspect_TypeOfDisplayText theDisplayType)
{
- if (myFont.IsEmpty())
+ SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
+ myShadingModel = Graphic3d_TOSM_UNLIT;
+ myTextStyle = theStyle;
+ myTextDisplayType = theDisplayType;
+ myInteriorColor.SetRGB (theColor);
+ myEdgeColor.SetRGB (Quantity_NOC_WHITE);
+ if (theFont != NULL
+ && *theFont != '\0')
{
- myFont = Font_NOF_ASCII_MONO;
- }
-
- if (theExpansionFactor <= 0.0)
- {
- throw Graphic3d_AspectTextDefinitionError("Bad value for TextScaleFactor");
+ myTextFont = new TCollection_HAsciiString (theFont);
}
}
#ifndef _Graphic3d_AspectText3d_HeaderFile
#define _Graphic3d_AspectText3d_HeaderFile
-#include <Aspect_TypeOfStyleText.hxx>
-#include <Aspect_TypeOfDisplayText.hxx>
-#include <Graphic3d_AspectTextDefinitionError.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Font_FontAspect.hxx>
-#include <Font_NameOfFont.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Real.hxx>
-#include <Standard_Type.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <Quantity_ColorRGBA.hxx>
+#include <Graphic3d_Aspects.hxx>
-//! Creates and updates a group of attributes for
-//! text primitives. This group contains the color,
-//! font, expansion factor (height/width ratio), and
-//! inter-character space.
-//!
-//! NOTE: The font name is stored in the aspect instance
-//! so it is safe to pass it as const char* to OpenGl package
-//! without copying the string. However, the aspect should not
-//! be deleted until the text drawn using this aspect is no longer
-//! visible. The best practice is to keep the aspect in the object's drawer.
-class Graphic3d_AspectText3d : public Standard_Transient
+//! Creates and updates a group of attributes for text primitives.
+class Graphic3d_AspectText3d : public Graphic3d_Aspects
{
- DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Standard_Transient)
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectText3d, Graphic3d_Aspects)
public:
- //! Creates a context table for text primitives
- //! defined with the following default values:
- //!
- //! Color : NOC_YELLOW
- //! Font : NOF_ASCII_MONO
- //! Expansion factor : 1.
- //! Space between characters : 0.
- //! The style : TOST_NORMAL
- //! The display type : TODT_NORMAL
+ //! Creates a context table for text primitives defined with the following default values:
+ //! Color : Quantity_NOC_YELLOW
+ //! Font : Font_NOF_ASCII_MONO
+ //! The style : Aspect_TOST_NORMAL
+ //! The display type : Aspect_TODT_NORMAL
Standard_EXPORT Graphic3d_AspectText3d();
- //! Creates a context table for text primitives
- //! defined with the specified values.
- //! AFont may be to take means from User(example "Courier New")
- //! or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
- //! or use default font("Courier")
- Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor,
- const Standard_CString theFont,
- const Standard_Real theExpansionFactor,
- const Standard_Real theSpace,
- const Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL,
- const Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL);
+ //! Creates a context table for text primitives defined with the specified values.
+ //! @param theColor [in] text color
+ //! @param theFont [in] font family name or alias like Font_NOF_ASCII_MONO
+ //! @param theExpansionFactor [in] deprecated parameter, has no effect
+ //! @param theSpace [in] deprecated parameter, has no effect
+ //! @param theStyle [in] font style
+ //! @param theDisplayType [in] display mode
+ Standard_EXPORT Graphic3d_AspectText3d (const Quantity_Color& theColor,
+ Standard_CString theFont,
+ Standard_Real theExpansionFactor,
+ Standard_Real theSpace,
+ Aspect_TypeOfStyleText theStyle = Aspect_TOST_NORMAL,
+ Aspect_TypeOfDisplayText theDisplayType = Aspect_TODT_NORMAL);
//! Return the text color.
- const Quantity_Color& Color() const { return myColor.GetRGB(); }
+ const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); }
//! Return the text color.
- const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
+ const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; }
//! Modifies the color.
- void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
+ void SetColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
//! Modifies the color.
- void SetColor (const Quantity_ColorRGBA& theColor) { myColor = theColor; }
+ void SetColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
- //! Modifies the expansion factor (height/width ratio)
- //! If the factor is less than 1, the characters will
- //! be higher than they are wide.
- void SetExpansionFactor (const Standard_Real theFactor)
+ //! Return the font.
+ const TCollection_AsciiString& Font() const
{
- if (theFactor <= 0.0)
+ if (myTextFont.IsNull())
{
- throw Graphic3d_AspectTextDefinitionError("Bad value for TextScaleFactor");
+ static const TCollection_AsciiString anEmpty;
+ return anEmpty;
}
- myFactor = theFactor;
+ return myTextFont->String();
}
- //! Return the font.
- const TCollection_AsciiString& Font() const { return myFont; }
-
//! Modifies the font.
void SetFont (const TCollection_AsciiString& theFont)
{
- myFont = !theFont.IsEmpty() ? theFont : TCollection_AsciiString (Font_NOF_ASCII_MONO);
+ if (!theFont.IsEmpty())
+ {
+ myTextFont = new TCollection_HAsciiString (theFont);
+ }
+ else
+ {
+ myTextFont.Nullify();
+ }
}
//! Modifies the font.
SetFont (TCollection_AsciiString (theFont));
}
- //! Return the space between characters.
- Standard_Real Space() const { return mySpace; }
-
- //! Modifies the space between the characters.
- void SetSpace (const Standard_Real theSpace) { mySpace = theSpace; }
-
//! Return the text style.
- Aspect_TypeOfStyleText Style() const { return myStyle; }
+ Aspect_TypeOfStyleText Style() const { return myTextStyle; }
//! Modifies the style of the text.
- //! * TOST_NORMAL
- //! Default text. The text is displayed like any other graphic object.
- //! This text can be hidden by another object that is nearest from the point of view.
- //! * TOST_ANNOTATION
- //! The text is always visible.
- //! The text is displayed over the other object according to the priority.
- void SetStyle (const Aspect_TypeOfStyleText theStyle) { myStyle = theStyle; }
+ void SetStyle (Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; }
//! Return display type.
- Aspect_TypeOfDisplayText DisplayType() const { return myDisplayType; }
+ Aspect_TypeOfDisplayText DisplayType() const { return myTextDisplayType; }
//! Define the display type of the text.
- //!
- //! TODT_NORMAL Default display. Text only.
- //! TODT_SUBTITLE There is a subtitle under the text.
- //! TODT_DEKALE The text is displayed with a 3D style.
- //! TODT_BLEND The text is displayed in XOR.
- //! TODT_DIMENSION Dimension line under text will be invisible.
- void SetDisplayType (const Aspect_TypeOfDisplayText theDisplayType) { myDisplayType = theDisplayType; }
-
- //! Return subtitle color.
- const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myColorSubTitle; }
-
- //! Return subtitle color.
- const Quantity_Color& ColorSubTitle() const { return myColorSubTitle.GetRGB(); }
-
- //! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType
- //! and the color of background for the TODT_DEKALE TextDisplayType.
- void SetColorSubTitle (const Quantity_Color& theColor) { myColorSubTitle.SetRGB (theColor); }
-
- //! Modifies the color of the subtitle for the TODT_SUBTITLE TextDisplayType
- //! and the color of background for the TODT_DEKALE TextDisplayType.
- void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myColorSubTitle = theColor; }
+ void SetDisplayType (Aspect_TypeOfDisplayText theDisplayType) { myTextDisplayType = theDisplayType; }
//! Returns TRUE when the Text Zoomable is on.
- bool GetTextZoomable() const { return myTextZoomable; }
-
- //! Turns usage of text zoomable on/off
- void SetTextZoomable (const bool theFlag) { myTextZoomable = theFlag; }
+ bool GetTextZoomable() const { return myIsTextZoomable; }
//! Returns Angle of degree
- Standard_Real GetTextAngle() const { return myTextAngle; }
+ Standard_ShortReal GetTextAngle() const { return myTextAngle; }
//! Turns usage of text rotated
- void SetTextAngle (const Standard_Real theAngle) { myTextAngle = theAngle; }
+ void SetTextAngle (const Standard_Real theAngle) { myTextAngle = (Standard_ShortReal )theAngle; }
//! Returns text FontAspect
Font_FontAspect GetTextFontAspect() const { return myTextFontAspect; }
- //! Turns usage of Aspect text
- void SetTextFontAspect (const Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; }
-
- //! Return the shader program.
- const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
-
- //! Sets up OpenGL/GLSL shader program.
- void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
-
-public:
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor = myFactor;
- theSpace = mySpace;
- }
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace,
- Aspect_TypeOfStyleText& theStyle,
- Aspect_TypeOfDisplayText& theDisplayType,
- Quantity_Color& theColorSubTitle) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor= myFactor;
- theSpace = mySpace;
- theStyle = myStyle;
- theDisplayType = myDisplayType;
- theColorSubTitle = myColorSubTitle.GetRGB();
- }
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace,
- Aspect_TypeOfStyleText& theStyle,
- Aspect_TypeOfDisplayText& theDisplayType,
- Quantity_Color& theColorSubTitle,
- Standard_Boolean& theTextZoomable,
- Standard_Real& theTextAngle) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor= myFactor;
- theSpace = mySpace;
- theStyle = myStyle;
- theDisplayType = myDisplayType;
- theColorSubTitle = myColorSubTitle.GetRGB();
-
- theTextZoomable = myTextZoomable;
- theTextAngle = myTextAngle;
- }
-
- //! Returns the current values of the group.
- Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
- void Values (Quantity_Color& theColor,
- Standard_CString& theFont,
- Standard_Real& theExpansionFactor,
- Standard_Real& theSpace,
- Aspect_TypeOfStyleText& theStyle,
- Aspect_TypeOfDisplayText& theDisplayType,
- Quantity_Color& theColorSubTitle,
- Standard_Boolean& theTextZoomable,
- Standard_Real& theTextAngle,
- Font_FontAspect& theTextFontAspect) const
- {
- theColor = myColor.GetRGB();
- theFont = myFont.ToCString();
- theExpansionFactor= myFactor;
- theSpace = mySpace;
- theStyle = myStyle;
- theDisplayType = myDisplayType;
- theColorSubTitle = myColorSubTitle.GetRGB();
-
- theTextZoomable = myTextZoomable;
- theTextAngle = myTextAngle;
- theTextFontAspect = myTextFontAspect;
- }
-
-protected:
-
- TCollection_AsciiString myFont;
- Quantity_ColorRGBA myColor;
- Standard_Real myFactor;
- Standard_Real mySpace;
- Aspect_TypeOfStyleText myStyle;
- Aspect_TypeOfDisplayText myDisplayType;
- Quantity_ColorRGBA myColorSubTitle;
- bool myTextZoomable;
- Standard_Real myTextAngle;
- Font_FontAspect myTextFontAspect;
- Handle(Graphic3d_ShaderProgram) myProgram;
-
};
-DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Standard_Transient)
+DEFINE_STANDARD_HANDLE(Graphic3d_AspectText3d, Graphic3d_Aspects)
#endif // _Graphic3d_AspectText3d_HeaderFile
+++ /dev/null
-// Created on: 1993-03-31
-// Created by: NW,JPB,CAL
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 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 _Graphic3d_AspectTextDefinitionError_HeaderFile
-#define _Graphic3d_AspectTextDefinitionError_HeaderFile
-
-#include <Standard_Type.hxx>
-#include <Standard_DefineException.hxx>
-#include <Standard_SStream.hxx>
-#include <Standard_OutOfRange.hxx>
-
-class Graphic3d_AspectTextDefinitionError;
-DEFINE_STANDARD_HANDLE(Graphic3d_AspectTextDefinitionError, Standard_OutOfRange)
-
-#if !defined No_Exception && !defined No_Graphic3d_AspectTextDefinitionError
- #define Graphic3d_AspectTextDefinitionError_Raise_if(CONDITION, MESSAGE) \
- if (CONDITION) throw Graphic3d_AspectTextDefinitionError(MESSAGE);
-#else
- #define Graphic3d_AspectTextDefinitionError_Raise_if(CONDITION, MESSAGE)
-#endif
-
-DEFINE_STANDARD_EXCEPTION(Graphic3d_AspectTextDefinitionError, Standard_OutOfRange)
-
-#endif // _Graphic3d_AspectTextDefinitionError_HeaderFile
--- /dev/null
+// Copyright (c) 2019 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.
+
+#include <Graphic3d_Aspects.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
+
+// =======================================================================
+// function : Graphic3d_Aspects
+// purpose :
+// =======================================================================
+Graphic3d_Aspects::Graphic3d_Aspects()
+: myInteriorColor (Quantity_NOC_CYAN1),
+ myBackInteriorColor (Quantity_NOC_CYAN1),
+ myEdgeColor (Quantity_NOC_WHITE),
+ myInteriorStyle (Aspect_IS_SOLID),
+ myShadingModel (Graphic3d_TOSM_DEFAULT),
+ myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
+ myAlphaCutoff (0.5f),
+ myLineType (Aspect_TOL_SOLID),
+ myLineWidth (1.0f),
+ myMarkerType (Aspect_TOM_POINT),
+ myMarkerScale (1.0f),
+ myTextStyle (Aspect_TOST_NORMAL),
+ myTextDisplayType (Aspect_TODT_NORMAL),
+ myTextFontAspect (Font_FontAspect_Regular),
+ myTextAngle (0.0f),
+ myToSkipFirstEdge (false),
+ myToDistinguishMaterials (false),
+ myToDrawEdges (false),
+ myToDrawSilhouette (false),
+ myToSuppressBackFaces (true),
+ myToMapTexture (false),
+ myIsTextZoomable (false)
+{
+ //
+}
+
+// =======================================================================
+// function : SetTextureMap
+// purpose :
+// =======================================================================
+void Graphic3d_Aspects::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture)
+{
+ if (theTexture.IsNull())
+ {
+ myTextureSet.Nullify();
+ return;
+ }
+
+ myTextureSet = new Graphic3d_TextureSet (theTexture);
+}
--- /dev/null
+// Copyright (c) 2019 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 _Graphic3d_Aspects_HeaderFile
+#define _Graphic3d_Aspects_HeaderFile
+
+#include <Aspect_PolygonOffsetMode.hxx>
+#include <Aspect_InteriorStyle.hxx>
+#include <Aspect_TypeOfDisplayText.hxx>
+#include <Aspect_TypeOfLine.hxx>
+#include <Aspect_TypeOfMarker.hxx>
+#include <Aspect_TypeOfStyleText.hxx>
+#include <Font_FontAspect.hxx>
+#include <Font_NameOfFont.hxx>
+#include <Graphic3d_AlphaMode.hxx>
+#include <Graphic3d_MarkerImage.hxx>
+#include <Graphic3d_HatchStyle.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
+#include <Graphic3d_PolygonOffset.hxx>
+#include <Graphic3d_ShaderProgram.hxx>
+#include <Graphic3d_TextureMap.hxx>
+#include <Graphic3d_TextureSet.hxx>
+#include <Graphic3d_TypeOfShadingModel.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+//! This class defines graphic attributes.
+class Graphic3d_Aspects : public Standard_Transient
+{
+ DEFINE_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
+public:
+
+ //! Creates a context table for drawing primitives defined with the following default values:
+ Standard_EXPORT Graphic3d_Aspects();
+
+ //! Return interior rendering style; Aspect_IS_SOLID by default.
+ Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; }
+
+ //! Modifies the interior type used for rendering
+ void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; }
+
+ //! Returns shading model; Graphic3d_TOSM_DEFAULT by default.
+ //! Graphic3d_TOSM_DEFAULT means that Shading Model set as default for entire Viewer will be used.
+ Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
+
+ //! Sets shading model
+ void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) { myShadingModel = theShadingModel; }
+
+ //! Returns the way how alpha value should be treated (Graphic3d_AlphaMode_BlendAuto by default, for backward compatibility).
+ Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
+
+ //! Returns alpha cutoff threshold, for discarding fragments within Graphic3d_AlphaMode_Mask mode (0.5 by default).
+ //! If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent.
+ Standard_ShortReal AlphaCutoff() const { return myAlphaCutoff; }
+
+ //! Defines the way how alpha value should be treated.
+ void SetAlphaMode (Graphic3d_AlphaMode theMode, Standard_ShortReal theAlphaCutoff = 0.5f)
+ {
+ myAlphaMode = theMode;
+ myAlphaCutoff = theAlphaCutoff;
+ }
+
+ //! Return color
+ const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; }
+
+ //! Return the color.
+ const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); }
+
+ //! Modifies the color.
+ void SetColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB(theColor); }
+
+ //! Return interior color.
+ const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); }
+
+ //! Return interior color.
+ const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; }
+
+ //! Modifies the color of the interior of the face
+ void SetInteriorColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); }
+
+ //! Modifies the color of the interior of the face
+ void SetInteriorColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
+
+ //! Return back interior color.
+ const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); }
+
+ //! Return back interior color.
+ const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; }
+
+ //! Modifies the color of the interior of the back face
+ void SetBackInteriorColor (const Quantity_Color& theColor) { myBackInteriorColor.SetRGB (theColor); }
+
+ //! Modifies the color of the interior of the back face
+ void SetBackInteriorColor (const Quantity_ColorRGBA& theColor) { myBackInteriorColor = theColor; }
+
+ //! Returns the surface material of external faces
+ const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; }
+
+ //! Returns the surface material of external faces
+ Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; }
+
+ //! Modifies the surface material of external faces
+ void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; }
+
+ //! Returns the surface material of internal faces
+ const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; }
+
+ //! Returns the surface material of internal faces
+ Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; }
+
+ //! Modifies the surface material of internal faces
+ void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; }
+
+ //! Returns true if back faces should be suppressed (true by default).
+ bool ToSuppressBackFaces() const { return myToSuppressBackFaces; }
+
+ //! Assign back faces culling flag.
+ void SetSuppressBackFaces (bool theToSuppress) { myToSuppressBackFaces = theToSuppress; }
+
+ //! Returns true if back faces should be suppressed (true by default).
+ bool BackFace() const { return myToSuppressBackFaces; }
+
+ //! Allows the display of back-facing filled polygons.
+ void AllowBackFace() { myToSuppressBackFaces = false; }
+
+ //! Suppress the display of back-facing filled polygons.
+ //! A back-facing polygon is defined as a polygon whose
+ //! vertices are in a clockwise order with respect to screen coordinates.
+ void SuppressBackFace() { myToSuppressBackFaces = true; }
+
+ //! Returns true if material properties should be distinguished for back and front faces (false by default).
+ bool Distinguish() const { return myToDistinguishMaterials; }
+
+ //! Set material distinction between front and back faces.
+ void SetDistinguish (bool toDistinguish) { myToDistinguishMaterials = toDistinguish; }
+
+ //! Allows material distinction between front and back faces.
+ void SetDistinguishOn() { myToDistinguishMaterials = true; }
+
+ //! Forbids material distinction between front and back faces.
+ void SetDistinguishOff() { myToDistinguishMaterials = false; }
+
+ //! Return shader program.
+ const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
+
+ //! Sets up OpenGL/GLSL shader program.
+ void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
+
+ //! Return texture array to be mapped.
+ const Handle(Graphic3d_TextureSet)& TextureSet() const { return myTextureSet; }
+
+ //! Setup texture array to be mapped.
+ void SetTextureSet (const Handle(Graphic3d_TextureSet)& theTextures) { myTextureSet = theTextures; }
+
+ //! Return texture to be mapped.
+ //Standard_DEPRECATED("Deprecated method, TextureSet() should be used instead")
+ Handle(Graphic3d_TextureMap) TextureMap() const
+ {
+ return !myTextureSet.IsNull() && !myTextureSet->IsEmpty()
+ ? myTextureSet->First()
+ : Handle(Graphic3d_TextureMap)();
+ }
+
+ //! Assign texture to be mapped.
+ //! See also SetTextureMapOn() to actually activate texture mapping.
+ //Standard_DEPRECATED("Deprecated method, SetTextureSet() should be used instead")
+ Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture);
+
+ //! Return true if texture mapping is enabled (false by default).
+ bool ToMapTexture() const { return myToMapTexture; }
+
+ //! Return true if texture mapping is enabled (false by default).
+ bool TextureMapState() const { return myToMapTexture; }
+
+ //! Enable or disable texture mapping (has no effect if texture is not set).
+ void SetTextureMapOn (bool theToMap) { myToMapTexture = theToMap; }
+
+ //! Enable texture mapping (has no effect if texture is not set).
+ void SetTextureMapOn() { myToMapTexture = true; }
+
+ //! Disable texture mapping.
+ void SetTextureMapOff() { myToMapTexture = false; }
+
+ //! Returns current polygon offsets settings.
+ const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
+
+ //! Sets polygon offsets settings.
+ void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; }
+
+ //! Returns current polygon offsets settings.
+ void PolygonOffsets (Standard_Integer& theMode,
+ Standard_ShortReal& theFactor,
+ Standard_ShortReal& theUnits) const
+ {
+ theMode = myPolygonOffset.Mode;
+ theFactor = myPolygonOffset.Factor;
+ theUnits = myPolygonOffset.Units;
+ }
+
+ //! Sets up OpenGL polygon offsets mechanism.
+ //! <aMode> parameter can contain various combinations of
+ //! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
+ //! that polygon offsets are not changed).
+ //! If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
+ //! arguments are used by graphic renderer to calculate a depth offset value:
+ //!
+ //! offset = <aFactor> * m + <aUnits> * r, where
+ //! m - maximum depth slope for the polygon currently being displayed,
+ //! r - minimum window coordinates depth resolution (implementation-specific)
+ //!
+ //! Default settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
+ //!
+ //! Negative offset values move polygons closer to the viewport,
+ //! while positive values shift polygons away.
+ //! Consult OpenGL reference for details (glPolygonOffset function description).
+ void SetPolygonOffsets (const Standard_Integer theMode,
+ const Standard_ShortReal theFactor = 1.0f,
+ const Standard_ShortReal theUnits = 0.0f)
+ {
+ myPolygonOffset.Mode = (Aspect_PolygonOffsetMode )(theMode & Aspect_POM_Mask);
+ myPolygonOffset.Factor = theFactor;
+ myPolygonOffset.Units = theUnits;
+ }
+
+//! @name parameters specific to Line primitive rendering
+public:
+
+ //! Return line type; Aspect_TOL_SOLID by default.
+ Aspect_TypeOfLine LineType() const { return myLineType; }
+
+ //! Modifies the line type
+ void SetLineType (Aspect_TypeOfLine theType) { myLineType = theType; }
+
+ //! Return width for edges in pixels; 1.0 by default.
+ Standard_ShortReal LineWidth() const { return myLineWidth; }
+
+ //! Modifies the line thickness
+ //! Warning: Raises Standard_OutOfRange if the width is a negative value.
+ void SetLineWidth (Standard_ShortReal theWidth)
+ {
+ if (theWidth <= 0.0f)
+ {
+ throw Standard_OutOfRange ("Bad value for EdgeLineWidth");
+ }
+ myLineWidth = theWidth;
+ }
+
+//! @name parameters specific to Point (Marker) primitive rendering
+public:
+
+ //! Return marker type; Aspect_TOM_POINT by default.
+ Aspect_TypeOfMarker MarkerType() const { return myMarkerType; }
+
+ //! Modifies the type of marker.
+ void SetMarkerType (Aspect_TypeOfMarker theType) { myMarkerType = theType; }
+
+ //! Return marker scale factor; 1.0 by default.
+ Standard_ShortReal MarkerScale() const { return myMarkerScale; }
+
+ //! Modifies the scale factor.
+ //! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor.
+ //! It is always the smallest displayable dot.
+ //! Warning: Raises Standard_OutOfRange if the scale is a negative value.
+ void SetMarkerScale (const Standard_ShortReal theScale)
+ {
+ if (theScale <= 0.0f)
+ {
+ throw Standard_OutOfRange ("Bad value for MarkerScale");
+ }
+ myMarkerScale = theScale;
+ }
+
+ //! Returns marker's image texture.
+ //! Could be null handle if marker aspect has been initialized as default type of marker.
+ const Handle(Graphic3d_MarkerImage)& MarkerImage() const { return myMarkerImage; }
+
+ //! Set marker's image texture.
+ void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
+
+//! @name parameters specific to text rendering
+public:
+
+ //! Returns the font; NULL string by default.
+ const Handle(TCollection_HAsciiString)& TextFont() const { return myTextFont; }
+
+ //! Modifies the font.
+ void SetTextFont (const Handle(TCollection_HAsciiString)& theFont) { myTextFont = theFont; }
+
+ //! Returns text FontAspect
+ Font_FontAspect TextFontAspect() const { return myTextFontAspect; }
+
+ //! Turns usage of Aspect text
+ void SetTextFontAspect (Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; }
+
+ //! Returns display type; Aspect_TODT_NORMAL by default.
+ Aspect_TypeOfDisplayText TextDisplayType() const { return myTextDisplayType; }
+
+ //! Sets display type.
+ void SetTextDisplayType (Aspect_TypeOfDisplayText theType) { myTextDisplayType = theType; }
+
+ //! Returns text background/shadow color; equals to EdgeColor() property.
+ const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myEdgeColor; }
+
+ //! Return text background/shadow color; equals to EdgeColor() property.
+ const Quantity_Color& ColorSubTitle() const { return myEdgeColor.GetRGB(); }
+
+ //! Modifies text background/shadow color; equals to EdgeColor() property.
+ void SetColorSubTitle (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
+
+ //! Modifies text background/shadow color; equals to EdgeColor() property.
+ void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
+
+ //! Returns TRUE when the Text Zoomable is on.
+ bool IsTextZoomable() const { return myIsTextZoomable; }
+
+ //! Turns usage of text zoomable on/off
+ void SetTextZoomable (bool theFlag) { myIsTextZoomable = theFlag; }
+
+ //! Returns the text style; Aspect_TOST_NORMAL by default.
+ Aspect_TypeOfStyleText TextStyle() const { return myTextStyle; }
+
+ //! Modifies the style of the text.
+ void SetTextStyle (Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; }
+
+ //! Returns Angle of degree
+ Standard_ShortReal TextAngle() const { return myTextAngle; }
+
+ //! Turns usage of text rotated
+ void SetTextAngle (Standard_ShortReal theAngle) { myTextAngle = (Standard_ShortReal )theAngle; }
+
+//! @name parameters specific to Mesh Edges (of triangulation primitive) rendering
+public:
+
+ //! Returns true if mesh edges should be drawn (false by default).
+ bool ToDrawEdges() const { return myToDrawEdges && myLineType != Aspect_TOL_EMPTY; }
+
+ //! Set if mesh edges should be drawn or not.
+ void SetDrawEdges (bool theToDraw)
+ {
+ myToDrawEdges = theToDraw;
+ if (myLineType == Aspect_TOL_EMPTY)
+ {
+ myLineType = Aspect_TOL_SOLID;
+ }
+ }
+
+ //! The edges of FillAreas are drawn.
+ void SetEdgeOn() { SetDrawEdges (true); }
+
+ //! The edges of FillAreas are not drawn.
+ void SetEdgeOff() { SetDrawEdges (false); }
+
+ //! Return color of edges.
+ const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
+
+ //! Return color of edges.
+ const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; }
+
+ //! Modifies the color of the edge of the face
+ void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
+
+ //! Modifies the color of the edge of the face
+ void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
+
+ //! Return edges line type (same as LineType()).
+ Aspect_TypeOfLine EdgeLineType() const { return myLineType; }
+
+ //! Modifies the edge line type (same as SetLineType())
+ void SetEdgeLineType (Aspect_TypeOfLine theType) { myLineType = theType; }
+
+ //! Return width for edges in pixels (same as LineWidth()).
+ Standard_ShortReal EdgeWidth() const { return myLineWidth; }
+
+ //! Modifies the edge thickness (same as SetLineWidth())
+ void SetEdgeWidth (Standard_Real theWidth) { SetLineWidth ((Standard_ShortReal )theWidth); }
+
+ //! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
+ //! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
+ //! This flag allows rendering wireframe presentation of quad-only array split into triangles.
+ //! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
+ //! 1------2
+ //! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3
+ //! 0------3
+ bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
+
+ //! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
+ void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
+
+ //! Returns TRUE if silhouette (outline) should be drawn (with edge color and width); FALSE by default.
+ bool ToDrawSilhouette() const { return myToDrawSilhouette; }
+
+ //! Enables/disables drawing silhouette (outline).
+ void SetDrawSilhouette (bool theToDraw) { myToDrawSilhouette = theToDraw; }
+
+public:
+
+ //! Returns the hatch type used when InteriorStyle is IS_HATCH
+ const Handle(Graphic3d_HatchStyle)& HatchStyle() const { return myHatchStyle; }
+
+ //! Modifies the hatch type used when InteriorStyle is IS_HATCH
+ void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle) { myHatchStyle = theStyle; }
+
+ //! Modifies the hatch type used when InteriorStyle is IS_HATCH
+ //! @warning This method always creates a new handle for a given hatch style
+ void SetHatchStyle (const Aspect_HatchStyle theStyle)
+ {
+ if (theStyle == Aspect_HS_SOLID)
+ {
+ myHatchStyle.Nullify();
+ return;
+ }
+
+ myHatchStyle = new Graphic3d_HatchStyle (theStyle);
+ }
+
+public:
+
+ //! Check for equality with another aspects.
+ bool IsEqual (const Graphic3d_Aspects& theOther)
+ {
+ if (this == &theOther)
+ {
+ return true;
+ }
+
+ return myProgram == theOther.myProgram
+ && myTextureSet == theOther.myTextureSet
+ && myMarkerImage == theOther.myMarkerImage
+ && myInteriorColor == theOther.myInteriorColor
+ && myBackInteriorColor == theOther.myBackInteriorColor
+ && myFrontMaterial == theOther.myFrontMaterial
+ && myBackMaterial == theOther.myBackMaterial
+ && myInteriorStyle == theOther.myInteriorStyle
+ && myShadingModel == theOther.myShadingModel
+ && myAlphaMode == theOther.myAlphaMode
+ && myAlphaCutoff == theOther.myAlphaCutoff
+ && myLineType == theOther.myLineType
+ && myEdgeColor == theOther.myEdgeColor
+ && myLineWidth == theOther.myLineWidth
+ && myMarkerType == theOther.myMarkerType
+ && myMarkerScale == theOther.myMarkerScale
+ && myHatchStyle == theOther.myHatchStyle
+ && myTextFont == theOther.myTextFont
+ && myPolygonOffset == theOther.myPolygonOffset
+ && myTextStyle == theOther.myTextStyle
+ && myTextDisplayType == theOther.myTextDisplayType
+ && myTextFontAspect == theOther.myTextFontAspect
+ && myTextAngle == theOther.myTextAngle
+ && myToSkipFirstEdge == theOther.myToSkipFirstEdge
+ && myToDistinguishMaterials == theOther.myToDistinguishMaterials
+ && myToDrawEdges == theOther.myToDrawEdges
+ && myToDrawSilhouette == theOther.myToDrawSilhouette
+ && myToSuppressBackFaces == theOther.myToSuppressBackFaces
+ && myToMapTexture == theOther.myToMapTexture
+ && myIsTextZoomable == theOther.myIsTextZoomable;
+ }
+
+protected:
+
+ Handle(Graphic3d_ShaderProgram) myProgram;
+ Handle(Graphic3d_TextureSet) myTextureSet;
+ Handle(Graphic3d_MarkerImage) myMarkerImage;
+ Handle(Graphic3d_HatchStyle) myHatchStyle;
+ Handle(TCollection_HAsciiString) myTextFont;
+ Graphic3d_MaterialAspect myFrontMaterial;
+ Graphic3d_MaterialAspect myBackMaterial;
+
+ Quantity_ColorRGBA myInteriorColor;
+ Quantity_ColorRGBA myBackInteriorColor;
+ Quantity_ColorRGBA myEdgeColor;
+
+ Graphic3d_PolygonOffset myPolygonOffset;
+ Aspect_InteriorStyle myInteriorStyle;
+ Graphic3d_TypeOfShadingModel myShadingModel;
+ Graphic3d_AlphaMode myAlphaMode;
+ Standard_ShortReal myAlphaCutoff;
+
+ Aspect_TypeOfLine myLineType;
+ Standard_ShortReal myLineWidth;
+
+ Aspect_TypeOfMarker myMarkerType;
+ Standard_ShortReal myMarkerScale;
+
+ Aspect_TypeOfStyleText myTextStyle;
+ Aspect_TypeOfDisplayText myTextDisplayType;
+ Font_FontAspect myTextFontAspect;
+ Standard_ShortReal myTextAngle;
+
+ bool myToSkipFirstEdge;
+ bool myToDistinguishMaterials;
+ bool myToDrawEdges;
+ bool myToDrawSilhouette;
+ bool myToSuppressBackFaces;
+ bool myToMapTexture;
+ bool myIsTextZoomable;
+
+};
+
+DEFINE_STANDARD_HANDLE(Graphic3d_Aspects, Standard_Transient)
+
+#endif // _Graphic3d_Aspects_HeaderFile
myStructure->StructureManager()->Update();
}
-// =======================================================================
-// function : IsGroupPrimitivesAspectSet
-// purpose :
-// =======================================================================
-Standard_Boolean Graphic3d_Group::IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const
-{
- switch (theAspect)
- {
- case Graphic3d_ASPECT_LINE: return !LineAspect().IsNull();
- case Graphic3d_ASPECT_TEXT: return !TextAspect().IsNull();
- case Graphic3d_ASPECT_MARKER: return !MarkerAspect().IsNull();
- case Graphic3d_ASPECT_FILL_AREA: return !FillAreaAspect().IsNull();
- default: return Standard_False;
- }
-}
-
-// =======================================================================
-// function : GroupPrimitivesAspect
-// purpose :
-// =======================================================================
-void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
- const Handle(Graphic3d_AspectText3d)& theAspText,
- const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
- const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
-{
- if (!theAspLine.IsNull())
- {
- Handle(Graphic3d_AspectLine3d) aLineAspect = LineAspect();
- if (!aLineAspect.IsNull())
- {
- *theAspLine.operator->() = *aLineAspect;
- }
- }
-
- if (!theAspText.IsNull())
- {
- Handle(Graphic3d_AspectText3d) aTextAspect = TextAspect();
- if (!aTextAspect.IsNull())
- {
- *theAspText.operator->() = *aTextAspect;
- }
- }
-
- if (!theAspMarker.IsNull())
- {
- Handle(Graphic3d_AspectMarker3d) aMarkerAspect = MarkerAspect();
- if (!aMarkerAspect.IsNull())
- {
- *theAspMarker.operator->() = *aMarkerAspect;
- }
- }
-
- if (!theAspFill.IsNull())
- {
- Handle(Graphic3d_AspectFillArea3d) aFillAspect = FillAreaAspect();
- if (!aFillAspect.IsNull())
- {
- *theAspFill.operator->() = *aFillAspect;
- }
- }
-}
-
// =======================================================================
// function : AddPrimitiveArray
// purpose :
#ifndef _Graphic3d_Group_HeaderFile
#define _Graphic3d_Group_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
#include <Graphic3d_BndBox4f.hxx>
-#include <Standard_Boolean.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
-#include <Standard_Transient.hxx>
-#include <Standard_Real.hxx>
+#include <Graphic3d_MapOfAspectsToAspects.hxx>
#include <Standard_CString.hxx>
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_TextPath.hxx>
#include <Graphic3d_IndexBuffer.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_BoundBuffer.hxx>
-#include <Standard_Address.hxx>
-#include <Graphic3d_GroupAspect.hxx>
#include <gp_Ax2.hxx>
#include <TCollection_ExtendedString.hxx>
public:
- //! Return line aspect.
- virtual Handle(Graphic3d_AspectLine3d) LineAspect() const = 0;
-
- //! Assign line aspect to the group.
- virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) = 0;
-
//! Return fill area aspect.
- virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const = 0;
+ virtual Handle(Graphic3d_Aspects) Aspects() const = 0;
//! Modifies the context for all the face primitives of the group.
- virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) = 0;
-
- //! Return text aspect.
- virtual Handle(Graphic3d_AspectText3d) TextAspect() const = 0;
-
- //! Modifies the context for all the text primitives of the group.
- virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) = 0;
-
- //! Return marker aspect.
- virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const = 0;
-
- //! Modifies the context for all the marker primitives of the group.
- virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0;
-
- //! Modifies the current context of the group to give
- //! another aspect for all the line primitives created
- //! after this call in the group.
- virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) = 0;
-
- //! Modifies the current context of the group to give
- //! another aspect for all the face primitives created
- //! after this call in the group.
- virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) = 0;
-
- //! Modifies the current context of the group to give
- //! another aspect for all the text primitives created
- //! after this call in the group.
- virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) = 0;
+ virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
- //! Modifies the current context of the group to give
- //! another aspect for all the marker primitives created
- //! after this call in the group.
- virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) = 0;
+ //! Modifies the current context of the group to give another aspect for all the primitives created after this call in the group.
+ virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) = 0;
//! Update presentation aspects after their modification.
virtual void SynchronizeAspects() = 0;
- //! Returns TRUE if aspect is set for the group.
- Standard_EXPORT Standard_Boolean IsGroupPrimitivesAspectSet (const Graphic3d_GroupAspect theAspect) const;
-
- //! Returns the context of all the primitives of the group.
- Standard_EXPORT void GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
- const Handle(Graphic3d_AspectText3d)& theAspText,
- const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
- const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const;
-
- //! Returns the last inserted context in the group for each kind of primitives.
- void PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspLine,
- const Handle(Graphic3d_AspectText3d)& theAspText,
- const Handle(Graphic3d_AspectMarker3d)& theAspMarker,
- const Handle(Graphic3d_AspectFillArea3d)& theAspFill) const
- {
- GroupPrimitivesAspect (theAspLine, theAspText, theAspMarker, theAspFill);
- }
+ //! Replace aspects specified in the replacement map.
+ virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) = 0;
public:
--- /dev/null
+// Copyright (c) 2019 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 _Graphic3d_MapOfAspectsToAspects_Header
+#define _Graphic3d_MapOfAspectsToAspects_Header
+
+#include <NCollection_DataMap.hxx>
+#include <Standard_Transient.hxx>
+
+class Graphic3d_Aspects;
+typedef NCollection_DataMap<Handle(Graphic3d_Aspects), Handle(Graphic3d_Aspects)> Graphic3d_MapOfAspectsToAspects;
+
+#endif // _Graphic3d_MapOfAspectsToAspects_Header
//! Empty constructor.
Graphic3d_PolygonOffset() : Mode(Aspect_POM_Fill), Factor (1.0f), Units (0.0f) {}
+
+ //! Equality comparison.
+ bool operator== (const Graphic3d_PolygonOffset& theOther) const
+ {
+ return Mode == theOther.Mode
+ && Factor == theOther.Factor
+ && Units == theOther.Units;
+ }
};
#endif // _Graphic3d_PolygonOffset_HeaderFile
!aDrawer->GetDouble ( MeshVS_DA_TextHeight, aHeight ) )
return;
- Prs3d_Root::NewGroup ( Prs );
- Handle (Graphic3d_Group) aTextGroup = Prs3d_Root::CurrentGroup ( Prs );
+ Handle(Graphic3d_Group) aTextGroup = Prs->NewGroup();
Quantity_Color AColor = Quantity_NOC_YELLOW;
-#ifdef _WIN32
- Standard_CString AFont = "Courier New";
-#else
- Standard_CString AFont = "Courier";
-#endif
+ Standard_CString AFont = Font_NOF_ASCII_MONO;
Standard_Real AExpansionFactor = 1.0;
Standard_Real ASpace = 0.0;
Aspect_TypeOfStyleText ATextStyle = Aspect_TOST_ANNOTATION;
Handle (Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ( AColor, AFont, AExpansionFactor, ASpace,
ATextStyle, ADisplayType );
aTextAspect->SetTextFontAspect( AFontAspectType );
- Handle (Graphic3d_AspectMarker3d) anAspectMarker3d =
- new Graphic3d_AspectMarker3d( Aspect_TOM_POINT, Quantity_NOC_GRAY, 1. );
- aTextGroup->SetPrimitivesAspect( aTextAspect );
- aTextGroup->SetPrimitivesAspect( anAspectMarker3d );
+ aTextGroup->SetGroupPrimitivesAspect( aTextAspect );
MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real));
TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes);
}
anIDs.Subtract( IDsToExclude );
- TColStd_MapIteratorOfPackedMapOfInteger it (anIDs);
- for( ; it.More(); it.Next() )
+ NCollection_Sequence<Graphic3d_Vec3> aPnts;
+ for (TColStd_MapIteratorOfPackedMapOfInteger it (anIDs); it.More(); it.Next())
{
Standard_Integer aKey = it.Key();
if( GetText ( IsElement, aKey, aStr ) )
continue;
}
+ aPnts.Append (Graphic3d_Vec3 ((float )X, (float )Y, (float )Z));
Graphic3d_Vertex aPoint (X, Y, Z);
- Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
- anArrayOfPoints->AddVertex (X, Y, Z);
- aTextGroup->AddPrimitiveArray (anArrayOfPoints);
aTextGroup->Text (aStr.ToCString(), aPoint, aHeight);
}
}
}
+ if (!aPnts.IsEmpty())
+ {
+ Handle(Graphic3d_Group) aMarkerGroup = Prs->NewGroup();
+ Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (aPnts.Size());
+ for (NCollection_Sequence<Graphic3d_Vec3>::Iterator aPntIter (aPnts); aPntIter.More(); aPntIter.Next())
+ {
+ const Graphic3d_Vec3& aPnt = aPntIter.Value();
+ anArrayOfPoints->AddVertex (aPnt.x(), aPnt.y(), aPnt.z());
+ }
+ Handle (Graphic3d_AspectMarker3d) anAspectMarker3d = new Graphic3d_AspectMarker3d (Aspect_TOM_POINT, Quantity_NOC_GRAY, 1.0);
+ aMarkerGroup->SetGroupPrimitivesAspect (anAspectMarker3d);
+ aMarkerGroup->AddPrimitiveArray (anArrayOfPoints);
+ }
+
if (!aCustomElements.IsEmpty())
CustomBuild ( Prs, aCustomElements, IDsToExclude, theDisplayMode );
}
OpenGl_ArbSamplerObject.hxx
OpenGl_ArbTBO.hxx
OpenGl_ArbTexBindless.hxx
-OpenGl_AspectFace.cxx
-OpenGl_AspectFace.hxx
-OpenGl_AspectLine.cxx
-OpenGl_AspectLine.hxx
-OpenGl_AspectMarker.cxx
-OpenGl_AspectMarker.hxx
-OpenGl_AspectText.cxx
-OpenGl_AspectText.hxx
+OpenGl_Aspects.cxx
+OpenGl_Aspects.hxx
+OpenGl_AspectsProgram.cxx
+OpenGl_AspectsProgram.hxx
+OpenGl_AspectsSprite.cxx
+OpenGl_AspectsSprite.hxx
+OpenGl_AspectsTextureSet.cxx
+OpenGl_AspectsTextureSet.hxx
OpenGl_FrameStats.cxx
OpenGl_FrameStats.hxx
OpenGl_FrameStatsPrs.cxx
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 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.
-
-#include <Aspect_PolygonOffsetMode.hxx>
-#include <NCollection_Vec3.hxx>
-
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_Context.hxx>
-#include <OpenGl_Sampler.hxx>
-#include <OpenGl_ShaderManager.hxx>
-#include <OpenGl_ShaderProgram.hxx>
-#include <OpenGl_Texture.hxx>
-#include <OpenGl_Workspace.hxx>
-
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Graphic3d_TextureMap.hxx>
-#include <Graphic3d_TextureParams.hxx>
-#include <Graphic3d_TypeOfReflection.hxx>
-#include <Graphic3d_MaterialAspect.hxx>
-
-#include <Image_PixMap.hxx>
-
-namespace
-{
- //! Initialize default material in this way for backward compatibility.
- inline Graphic3d_MaterialAspect initDefaultMaterial()
- {
- Graphic3d_MaterialAspect aMat;
- aMat.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
- aMat.SetAmbient (0.2f);
- aMat.SetDiffuse (0.8f);
- aMat.SetSpecular (0.1f);
- aMat.SetEmissive (0.0f);
- aMat.SetAmbientColor (Quantity_NOC_WHITE);
- aMat.SetDiffuseColor (Quantity_NOC_WHITE);
- aMat.SetEmissiveColor(Quantity_NOC_WHITE);
- aMat.SetSpecularColor(Quantity_NOC_WHITE);
- aMat.SetShininess (10.0f / 128.0f);
- aMat.SetRefractionIndex (1.0f);
- return aMat;
- }
-
- static const TCollection_AsciiString THE_EMPTY_KEY;
- static const Graphic3d_MaterialAspect THE_DEFAULT_MATERIAL = initDefaultMaterial();
-}
-
-// =======================================================================
-// function : OpenGl_AspectFace
-// purpose :
-// =======================================================================
-OpenGl_AspectFace::OpenGl_AspectFace()
-: myAspect (new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE,
- Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0,
- THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
- myShadingModel (Graphic3d_TOSM_UNLIT)
-{
- myAspect->SetShadingModel (myShadingModel);
- myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
-}
-
-// =======================================================================
-// function : OpenGl_AspectFace
-// purpose :
-// =======================================================================
-OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
-: myShadingModel (Graphic3d_TOSM_DEFAULT)
-{
- SetAspect (theAspect);
-}
-
-// =======================================================================
-// function : SetAspect
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
-{
- myAspect = theAspect;
-
- const Graphic3d_MaterialAspect& aMat = theAspect->FrontMaterial();
- myShadingModel = theAspect->ShadingModel() != Graphic3d_TOSM_UNLIT
- && (aMat.ReflectionMode (Graphic3d_TOR_AMBIENT)
- || aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)
- || aMat.ReflectionMode (Graphic3d_TOR_SPECULAR)
- || aMat.ReflectionMode (Graphic3d_TOR_EMISSION))
- ? theAspect->ShadingModel()
- : Graphic3d_TOSM_UNLIT;
-
- myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor());
- myAspectEdge.Aspect()->SetType (theAspect->EdgeLineType());
- myAspectEdge.Aspect()->SetWidth (theAspect->EdgeWidth());
-
- // update texture binding
- myResources.UpdateTexturesRediness (myAspect->TextureSet());
-
- // update shader program binding
- const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
- if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
- {
- myResources.ResetShaderReadiness();
- }
-}
-
-// =======================================================================
-// function : Render
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
-{
- theWorkspace->SetAspectFace (this);
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::Release (OpenGl_Context* theContext)
-{
- myResources.ReleaseTextures (theContext);
- if (!myResources.ShaderProgram.IsNull()
- && theContext)
- {
- theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
- myResources.ShaderProgram);
- }
- myResources.ShaderProgramId.Clear();
- myResources.ResetShaderReadiness();
-}
-
-// =======================================================================
-// function : ReleaseTextures
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::Resources::ReleaseTextures (OpenGl_Context* theCtx)
-{
- if (myTextures.IsNull())
- {
- return;
- }
-
- for (OpenGl_TextureSet::Iterator aTextureIter (myTextures); aTextureIter.More(); aTextureIter.Next())
- {
- Handle(OpenGl_Texture)& aTextureRes = aTextureIter.ChangeValue();
- if (aTextureRes.IsNull())
- {
- continue;
- }
-
- if (theCtx != NULL)
- {
- if (aTextureRes->ResourceId().IsEmpty())
- {
- theCtx->DelayedRelease (aTextureRes);
- }
- else
- {
- const TCollection_AsciiString aName = aTextureRes->ResourceId();
- aTextureRes.Nullify(); // we need nullify all handles before ReleaseResource() call
- theCtx->ReleaseResource (aName, Standard_True);
- }
- }
- aTextureRes.Nullify();
- }
- myIsTextureReady = Standard_False;
-}
-
-// =======================================================================
-// function : UpdateTexturesRediness
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::Resources::UpdateTexturesRediness (const Handle(Graphic3d_TextureSet)& theTextures)
-{
- const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
- const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
- if (aNbTexturesOld != aNbTexturesNew)
- {
- myIsTextureReady = Standard_False;
- return;
- }
- if (aNbTexturesOld == 0)
- {
- return;
- }
-
- Graphic3d_TextureSet::Iterator aTextureIter (theTextures);
- OpenGl_TextureSet::Iterator aResIter (myTextures);
- for (; aResIter.More(); aResIter.Next(), aTextureIter.Next())
- {
- const Handle(OpenGl_Texture)& aResource = aResIter.Value();
- const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
- if (aTexture.IsNull() != aResource.IsNull())
- {
- myIsTextureReady = Standard_False;
- return;
- }
- else if (aTexture.IsNull())
- {
- continue;
- }
-
- const TCollection_AsciiString& aTextureKey = aTexture->GetId();
- if (aTextureKey.IsEmpty() || aResource->ResourceId() != aTextureKey)
- {
- myIsTextureReady = Standard_False;
- return;
- }
- else if (aResource->Revision() != aTexture->Revision())
- {
- myIsTextureReady = Standard_False;
- return;
- }
- else
- {
- // just invalidate texture parameters
- aResource->Sampler()->SetParameters (aTexture->GetParams());
- }
- }
-}
-
-// =======================================================================
-// function : BuildTextures
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::Resources::BuildTextures (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_TextureSet)& theTextures)
-{
- // release old texture resources
- const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
- const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
- if (aNbTexturesOld != aNbTexturesNew)
- {
- ReleaseTextures (theCtx.get());
- if (aNbTexturesNew > 0)
- {
- myTextures = new OpenGl_TextureSet (theTextures->Size());
- }
- else
- {
- myTextures.Nullify();
- }
- }
- if (myTextures.IsNull())
- {
- return;
- }
-
- Graphic3d_TextureSet::Iterator aTextureIter (theTextures);
- OpenGl_TextureSet::Iterator aResIter (myTextures);
- for (; aResIter.More(); aResIter.Next(), aTextureIter.Next())
- {
- Handle(OpenGl_Texture)& aResource = aResIter.ChangeValue();
- const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
- if (!aResource.IsNull())
- {
- if (!aTexture.IsNull()
- && aTexture->GetId() == aResource->ResourceId()
- && aTexture->Revision() != aResource->Revision())
- {
- if (Handle(Image_PixMap) anImage = aTexture->GetImage())
- {
- aResource->Sampler()->SetParameters (aTexture->GetParams());
- aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
- aResource->SetRevision (aTexture->Revision());
- continue;
- }
- }
-
- if (aResource->ResourceId().IsEmpty())
- {
- theCtx->DelayedRelease (aResource);
- aResource.Nullify();
- }
- else
- {
- const TCollection_AsciiString aTextureKey = aResource->ResourceId();
- aResource.Nullify(); // we need nullify all handles before ReleaseResource() call
- theCtx->ReleaseResource (aTextureKey, Standard_True);
- }
- }
-
- if (!aTexture.IsNull())
- {
- const TCollection_AsciiString& aTextureKeyNew = aTexture->GetId();
- if (aTextureKeyNew.IsEmpty()
- || !theCtx->GetResource<Handle(OpenGl_Texture)> (aTextureKeyNew, aResource))
- {
- aResource = new OpenGl_Texture (aTextureKeyNew, aTexture->GetParams());
- if (Handle(Image_PixMap) anImage = aTexture->GetImage())
- {
- aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
- aResource->SetRevision (aTexture->Revision());
- }
- if (!aTextureKeyNew.IsEmpty())
- {
- theCtx->ShareResource (aTextureKeyNew, aResource);
- }
- }
- else
- {
- aResource->Sampler()->SetParameters (aTexture->GetParams());
- }
- }
- }
-}
-
-// =======================================================================
-// function : BuildShader
-// purpose :
-// =======================================================================
-void OpenGl_AspectFace::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader)
-{
- if (theCtx->core20fwd == NULL)
- {
- return;
- }
-
- // release old shader program resources
- if (!ShaderProgram.IsNull())
- {
- theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
- ShaderProgramId.Clear();
- ShaderProgram.Nullify();
- }
- if (theShader.IsNull())
- {
- return;
- }
-
- theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
-}
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 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 _OpenGl_AspectFace_Header
-#define _OpenGl_AspectFace_Header
-
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_TextureSet.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <Graphic3d_TextureMap.hxx>
-#include <Graphic3d_BSDF.hxx>
-
-class OpenGl_Texture;
-
-//! The element holding Graphic3d_AspectFillArea3d.
-class OpenGl_AspectFace : public OpenGl_Element
-{
-
-public:
-
- //! Empty constructor.
- Standard_EXPORT OpenGl_AspectFace();
-
- //! Create and assign parameters.
- Standard_EXPORT OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
-
- //! Return aspect.
- const Handle(Graphic3d_AspectFillArea3d)& Aspect() const { return myAspect; }
-
- //! Assign parameters.
- Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect);
-
- //! Set edge aspect.
- void SetAspectEdge (const OpenGl_AspectLine* theAspectEdge) { myAspectEdge = *theAspectEdge; }
-
- //! @return edge aspect.
- const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; }
-
- //! Returns Shading Model.
- Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
-
- //! Set if lighting should be disabled or not.
- void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
-
- //! Returns textures map.
- const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsTextureReady())
- {
- myResources.BuildTextures (theCtx, myAspect->TextureSet());
- myResources.SetTextureReady();
- }
- return myResources.TextureSet();
- }
-
- //! Init and return OpenGl shader program resource.
- //! @return shader program resource.
- const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsShaderReady())
- {
- myResources.BuildShader (theCtx, myAspect->ShaderProgram());
- myResources.SetShaderReady();
- }
-
- return myResources.ShaderProgram;
- }
-
- Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
- Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
-
- //! Update presentation aspects parameters after their modification.
- virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
-
-protected:
-
- //! OpenGl resources
- mutable struct Resources
- {
- public:
- //! Empty constructor.
- Resources()
- : myIsTextureReady (Standard_False),
- myIsShaderReady (Standard_False) {}
-
- //! Return TRUE if texture resource is up-to-date.
- Standard_Boolean IsTextureReady() const { return myIsTextureReady; }
-
- //! Return TRUE if shader resource is up-to-date.
- Standard_Boolean IsShaderReady () const { return myIsShaderReady; }
-
- //! Set texture resource up-to-date state.
- void SetTextureReady() { myIsTextureReady = Standard_True; }
-
- //! Set shader resource up-to-date state.
- void SetShaderReady () { myIsShaderReady = Standard_True; }
-
- //! Reset shader resource up-to-date state.
- void ResetShaderReadiness () { myIsShaderReady = Standard_False; }
-
- //! Return textures array.
- const Handle(OpenGl_TextureSet)& TextureSet() const { return myTextures; }
-
- //! Update texture resource up-to-date state.
- Standard_EXPORT void UpdateTexturesRediness (const Handle(Graphic3d_TextureSet)& theTextures);
-
- //! Build texture resource.
- Standard_EXPORT void BuildTextures (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_TextureSet)& theTextures);
-
- //! Build shader resource.
- Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader);
-
- //! Release texture resource.
- Standard_EXPORT void ReleaseTextures (OpenGl_Context* theCtx);
-
- Handle(OpenGl_ShaderProgram) ShaderProgram;
- TCollection_AsciiString ShaderProgramId;
-
- private:
-
- Handle(OpenGl_TextureSet) myTextures;
- Standard_Boolean myIsTextureReady;
- Standard_Boolean myIsShaderReady;
-
- } myResources;
-
- Handle(Graphic3d_AspectFillArea3d) myAspect;
- OpenGl_AspectLine myAspectEdge;
- Graphic3d_TypeOfShadingModel myShadingModel;
-
-public:
-
- DEFINE_STANDARD_ALLOC
-
-};
-
-#endif //_OpenGl_AspectFace_Header
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 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.
-
-#include <Graphic3d_ShaderProgram.hxx>
-
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_Context.hxx>
-#include <OpenGl_ShaderManager.hxx>
-#include <OpenGl_ShaderProgram.hxx>
-#include <OpenGl_Workspace.hxx>
-
-namespace
-{
- static const TCollection_AsciiString THE_EMPTY_KEY;
-}
-
-// =======================================================================
-// function : OpenGl_AspectLine
-// purpose :
-// =======================================================================
-OpenGl_AspectLine::OpenGl_AspectLine()
-: myAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0))
-{
- //
-}
-
-// =======================================================================
-// function : OpenGl_AspectLine
-// purpose :
-// =======================================================================
-OpenGl_AspectLine::OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect)
-{
- SetAspect (theAspect);
-}
-
-// =======================================================================
-// function : SetAspect
-// purpose :
-// =======================================================================
-void OpenGl_AspectLine::SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
-{
- myAspect = theAspect;
- const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
- if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
- {
- myResources.ResetShaderReadiness();
- }
-}
-
-// =======================================================================
-// function : Render
-// purpose :
-// =======================================================================
-void OpenGl_AspectLine::Render (const Handle(OpenGl_Workspace) &theWorkspace) const
-{
- theWorkspace->SetAspectLine (this);
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void OpenGl_AspectLine::Release (OpenGl_Context* theContext)
-{
- if (!myResources.ShaderProgram.IsNull()
- && theContext)
- {
- theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
- myResources.ShaderProgram);
- }
- myResources.ShaderProgramId.Clear();
- myResources.ResetShaderReadiness();
-}
-
-// =======================================================================
-// function : BuildShader
-// purpose :
-// =======================================================================
-void OpenGl_AspectLine::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader)
-{
- if (theCtx->core20fwd == NULL)
- {
- return;
- }
-
- // release old shader program resources
- if (!ShaderProgram.IsNull())
- {
- theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
- ShaderProgramId.Clear();
- ShaderProgram.Nullify();
- }
- if (theShader.IsNull())
- {
- return;
- }
-
- theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
-}
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 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 _OpenGl_AspectLine_Header
-#define _OpenGl_AspectLine_Header
-
-#include <TCollection_AsciiString.hxx>
-
-#include <Graphic3d_AspectLine3d.hxx>
-#include <OpenGl_Element.hxx>
-
-class OpenGl_ShaderProgram;
-
-//! The element holding Graphic3d_AspectLine3d.
-class OpenGl_AspectLine : public OpenGl_Element
-{
-public:
-
- //! Empty constructor.
- Standard_EXPORT OpenGl_AspectLine();
-
- //! Create and assign line aspect.
- Standard_EXPORT OpenGl_AspectLine (const Handle(Graphic3d_AspectLine3d)& theAspect);
-
- //! Return line aspect.
- const Handle(Graphic3d_AspectLine3d)& Aspect() const { return myAspect; }
-
- //! Assign line aspect.
- Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectLine3d)& theAspect);
-
- //! Init and return OpenGl shader program resource.
- //! @return shader program resource.
- const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsShaderReady())
- {
- myResources.BuildShader (theCtx, myAspect->ShaderProgram());
- myResources.SetShaderReady();
- }
-
- return myResources.ShaderProgram;
- }
-
- Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
- Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
-
- //! Update presentation aspects parameters after their modification.
- virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
-
-protected:
-
- //! OpenGl resources
- mutable struct Resources
- {
- public:
- Resources() : myIsShaderReady (Standard_False) {}
-
- Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
- void SetShaderReady() { myIsShaderReady = Standard_True; }
- void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
-
- Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader);
-
- Handle(OpenGl_ShaderProgram) ShaderProgram;
- TCollection_AsciiString ShaderProgramId;
-
- private:
-
- Standard_Boolean myIsShaderReady;
-
- } myResources;
- Handle(Graphic3d_AspectLine3d) myAspect;
-
- public:
- DEFINE_STANDARD_ALLOC
-};
-
-#endif //_OpenGl_AspectLine_Header
+++ /dev/null
-// Created on: 2011-07-14
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 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.
-
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_Context.hxx>
-#include <OpenGl_GraphicDriver.hxx>
-#include <OpenGl_PointSprite.hxx>
-#include <OpenGl_ShaderManager.hxx>
-#include <OpenGl_ShaderProgram.hxx>
-#include <OpenGl_Workspace.hxx>
-
-#include <Image_PixMap.hxx>
-#include <Graphic3d_MarkerImage.hxx>
-#include <Graphic3d_ShaderProgram.hxx>
-#include <NCollection_Vec4.hxx>
-#include <TColStd_HArray1OfByte.hxx>
-
-namespace
-{
- static const TCollection_AsciiString THE_EMPTY_KEY;
-
- //! Draw inner point as filled rectangle
- static Handle(TColStd_HArray1OfByte) fillPointBitmap (const Standard_Integer theSize)
- {
- // draw inner point as filled rectangle
- const Standard_Integer aNumOfBytes = (theSize / 8 + (theSize % 8 ? 1 : 0)) * theSize;
- Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
- for (Standard_Integer anIter = 0; anIter < aBitMap->Length(); ++anIter)
- {
- aBitMap->SetValue (anIter, 255);
- }
- return aBitMap;
- }
-}
-
-// Following Section relates to default markers
-
-#define TEL_NO_OF_SIZES 13
-#define TEL_PM_START_SIZE 1.0
-#define TEL_PM_END_SIZE 7.0
-
-struct PM_FONT_INFO
-{
- float width, height;
- int offset;
-};
-typedef PM_FONT_INFO* pm_font_info;
-
-#define PM_PLUS_10_NUM 9*2
-#define PM_PLUS_15_NUM 11*2
-#define PM_PLUS_20_NUM 13*2
-#define PM_PLUS_25_NUM 15*2
-#define PM_PLUS_30_NUM 17*3
-#define PM_PLUS_35_NUM 19*3
-#define PM_PLUS_40_NUM 21*3
-#define PM_PLUS_45_NUM 23*3
-#define PM_PLUS_50_NUM 25*4
-#define PM_PLUS_55_NUM 27*4
-#define PM_PLUS_60_NUM 29*4
-#define PM_PLUS_65_NUM 31*4
-#define PM_PLUS_70_NUM 32*4
-
-#define PM_STAR_10_NUM 9
-#define PM_STAR_15_NUM 11*2
-#define PM_STAR_20_NUM 13*2
-#define PM_STAR_25_NUM 15*2
-#define PM_STAR_30_NUM 17*2
-#define PM_STAR_35_NUM 19*2
-#define PM_STAR_40_NUM 21*3
-#define PM_STAR_45_NUM 23*3
-#define PM_STAR_50_NUM 25*3
-#define PM_STAR_55_NUM 27*3
-#define PM_STAR_60_NUM 29*4
-#define PM_STAR_65_NUM 32*4
-#define PM_STAR_70_NUM 32*4
-
-#define PM_CIRC_10_NUM 7
-#define PM_CIRC_15_NUM 9*2
-#define PM_CIRC_20_NUM 9*2
-#define PM_CIRC_25_NUM 11*2
-#define PM_CIRC_30_NUM 13*2
-#define PM_CIRC_35_NUM 15*2
-#define PM_CIRC_40_NUM 17*3
-#define PM_CIRC_45_NUM 19*3
-#define PM_CIRC_50_NUM 21*3
-#define PM_CIRC_55_NUM 23*3
-#define PM_CIRC_60_NUM 25*4
-#define PM_CIRC_65_NUM 27*4
-#define PM_CIRC_70_NUM 29*4
-
-#define PM_CROSS_10_NUM 7
-#define PM_CROSS_15_NUM 9*2
-#define PM_CROSS_20_NUM 11*2
-#define PM_CROSS_25_NUM 13*2
-#define PM_CROSS_30_NUM 15*2
-#define PM_CROSS_35_NUM 17*3
-#define PM_CROSS_40_NUM 19*3
-#define PM_CROSS_45_NUM 21*3
-#define PM_CROSS_50_NUM 23*3
-#define PM_CROSS_55_NUM 25*4
-#define PM_CROSS_60_NUM 27*4
-#define PM_CROSS_65_NUM 32*4
-#define PM_CROSS_70_NUM 32*4
-
-#define PM_PLUS_10_OFT 0
-#define PM_PLUS_15_OFT PM_PLUS_10_OFT + PM_PLUS_10_NUM
-#define PM_PLUS_20_OFT PM_PLUS_15_OFT + PM_PLUS_15_NUM
-#define PM_PLUS_25_OFT PM_PLUS_20_OFT + PM_PLUS_20_NUM
-#define PM_PLUS_30_OFT PM_PLUS_25_OFT + PM_PLUS_25_NUM
-#define PM_PLUS_35_OFT PM_PLUS_30_OFT + PM_PLUS_30_NUM
-#define PM_PLUS_40_OFT PM_PLUS_35_OFT + PM_PLUS_35_NUM
-#define PM_PLUS_45_OFT PM_PLUS_40_OFT + PM_PLUS_40_NUM
-#define PM_PLUS_50_OFT PM_PLUS_45_OFT + PM_PLUS_45_NUM
-#define PM_PLUS_55_OFT PM_PLUS_50_OFT + PM_PLUS_50_NUM
-#define PM_PLUS_60_OFT PM_PLUS_55_OFT + PM_PLUS_55_NUM
-#define PM_PLUS_65_OFT PM_PLUS_60_OFT + PM_PLUS_60_NUM
-#define PM_PLUS_70_OFT PM_PLUS_65_OFT + PM_PLUS_65_NUM
-
-#define PM_STAR_10_OFT PM_PLUS_70_OFT + PM_PLUS_70_NUM
-#define PM_STAR_15_OFT PM_STAR_10_OFT + PM_STAR_10_NUM
-#define PM_STAR_20_OFT PM_STAR_15_OFT + PM_STAR_15_NUM
-#define PM_STAR_25_OFT PM_STAR_20_OFT + PM_STAR_20_NUM
-#define PM_STAR_30_OFT PM_STAR_25_OFT + PM_STAR_25_NUM
-#define PM_STAR_35_OFT PM_STAR_30_OFT + PM_STAR_30_NUM
-#define PM_STAR_40_OFT PM_STAR_35_OFT + PM_STAR_35_NUM
-#define PM_STAR_45_OFT PM_STAR_40_OFT + PM_STAR_40_NUM
-#define PM_STAR_50_OFT PM_STAR_45_OFT + PM_STAR_45_NUM
-#define PM_STAR_55_OFT PM_STAR_50_OFT + PM_STAR_50_NUM
-#define PM_STAR_60_OFT PM_STAR_55_OFT + PM_STAR_55_NUM
-#define PM_STAR_65_OFT PM_STAR_60_OFT + PM_STAR_60_NUM
-#define PM_STAR_70_OFT PM_STAR_65_OFT + PM_STAR_65_NUM
-
-#define PM_CIRC_10_OFT PM_STAR_70_OFT + PM_STAR_70_NUM
-#define PM_CIRC_15_OFT PM_CIRC_10_OFT + PM_CIRC_10_NUM
-#define PM_CIRC_20_OFT PM_CIRC_15_OFT + PM_CIRC_15_NUM
-#define PM_CIRC_25_OFT PM_CIRC_20_OFT + PM_CIRC_20_NUM
-#define PM_CIRC_30_OFT PM_CIRC_25_OFT + PM_CIRC_25_NUM
-#define PM_CIRC_35_OFT PM_CIRC_30_OFT + PM_CIRC_30_NUM
-#define PM_CIRC_40_OFT PM_CIRC_35_OFT + PM_CIRC_35_NUM
-#define PM_CIRC_45_OFT PM_CIRC_40_OFT + PM_CIRC_40_NUM
-#define PM_CIRC_50_OFT PM_CIRC_45_OFT + PM_CIRC_45_NUM
-#define PM_CIRC_55_OFT PM_CIRC_50_OFT + PM_CIRC_50_NUM
-#define PM_CIRC_60_OFT PM_CIRC_55_OFT + PM_CIRC_55_NUM
-#define PM_CIRC_65_OFT PM_CIRC_60_OFT + PM_CIRC_60_NUM
-#define PM_CIRC_70_OFT PM_CIRC_65_OFT + PM_CIRC_65_NUM
-
-#define PM_CROSS_10_OFT PM_CIRC_70_OFT + PM_CIRC_70_NUM
-#define PM_CROSS_15_OFT PM_CROSS_10_OFT + PM_CROSS_10_NUM
-#define PM_CROSS_20_OFT PM_CROSS_15_OFT + PM_CROSS_15_NUM
-#define PM_CROSS_25_OFT PM_CROSS_20_OFT + PM_CROSS_20_NUM
-#define PM_CROSS_30_OFT PM_CROSS_25_OFT + PM_CROSS_25_NUM
-#define PM_CROSS_35_OFT PM_CROSS_30_OFT + PM_CROSS_30_NUM
-#define PM_CROSS_40_OFT PM_CROSS_35_OFT + PM_CROSS_35_NUM
-#define PM_CROSS_45_OFT PM_CROSS_40_OFT + PM_CROSS_40_NUM
-#define PM_CROSS_50_OFT PM_CROSS_45_OFT + PM_CROSS_45_NUM
-#define PM_CROSS_55_OFT PM_CROSS_50_OFT + PM_CROSS_50_NUM
-#define PM_CROSS_60_OFT PM_CROSS_55_OFT + PM_CROSS_55_NUM
-#define PM_CROSS_65_OFT PM_CROSS_60_OFT + PM_CROSS_60_NUM
-#define PM_CROSS_70_OFT PM_CROSS_65_OFT + PM_CROSS_65_NUM
-
-static const PM_FONT_INFO arrPMFontInfo[][TEL_NO_OF_SIZES] =
-{
- // TOM_POINT - not used
- {{0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0},
- {0, 0, 0}},
-
- // TOM_PLUS
- {{ 9.f, 9.f, PM_PLUS_10_OFT},
- {11.f, 11.f, PM_PLUS_15_OFT},
- {13.f, 13.f, PM_PLUS_20_OFT},
- {15.f, 15.f, PM_PLUS_25_OFT},
- {17.f, 17.f, PM_PLUS_30_OFT},
- {19.f, 19.f, PM_PLUS_35_OFT},
- {21.f, 21.f, PM_PLUS_40_OFT},
- {23.f, 23.f, PM_PLUS_45_OFT},
- {25.f, 25.f, PM_PLUS_50_OFT},
- {27.f, 27.f, PM_PLUS_55_OFT},
- {29.f, 29.f, PM_PLUS_60_OFT},
- {31.f, 31.f, PM_PLUS_65_OFT},
- {32.f, 32.f, PM_PLUS_70_OFT}},
-
- // TOM_STAR
- {{ 7.f, 9.f, PM_STAR_10_OFT},
- {9.f, 11.f, PM_STAR_15_OFT},
- {11.f, 13.f, PM_STAR_20_OFT},
- {13.f, 15.f, PM_STAR_25_OFT},
- {13.f, 17.f, PM_STAR_30_OFT},
- {15.f, 19.f, PM_STAR_35_OFT},
- {17.f, 21.f, PM_STAR_40_OFT},
- {19.f, 23.f, PM_STAR_45_OFT},
- {21.f, 25.f, PM_STAR_50_OFT},
- {23.f, 27.f, PM_STAR_55_OFT},
- {25.f, 29.f, PM_STAR_60_OFT},
- {32.f, 32.f, PM_STAR_65_OFT},
- {32.f, 32.f, PM_STAR_70_OFT}},
-
- // TOM_X
- {{ 7.f, 7.f, PM_CROSS_10_OFT},
- { 9.f, 9.f, PM_CROSS_15_OFT},
- {11.f, 11.f, PM_CROSS_20_OFT},
- {13.f, 13.f, PM_CROSS_25_OFT},
- {15.f, 15.f, PM_CROSS_30_OFT},
- {17.f, 17.f, PM_CROSS_35_OFT},
- {19.f, 19.f, PM_CROSS_40_OFT},
- {21.f, 21.f, PM_CROSS_45_OFT},
- {23.f, 23.f, PM_CROSS_50_OFT},
- {25.f, 25.f, PM_CROSS_55_OFT},
- {27.f, 27.f, PM_CROSS_60_OFT},
- {32.f, 32.f, PM_CROSS_65_OFT},
- {32.f, 32.f, PM_CROSS_70_OFT}},
-
- // TOM_O
- {{ 7.f, 7.f, PM_CIRC_10_OFT},
- { 9.f, 9.f, PM_CIRC_15_OFT},
- { 9.f, 9.f, PM_CIRC_20_OFT},
- {11.f, 11.f, PM_CIRC_25_OFT},
- {13.f, 13.f, PM_CIRC_30_OFT},
- {15.f, 15.f, PM_CIRC_35_OFT},
- {17.f, 17.f, PM_CIRC_40_OFT},
- {19.f, 19.f, PM_CIRC_45_OFT},
- {21.f, 21.f, PM_CIRC_50_OFT},
- {23.f, 23.f, PM_CIRC_55_OFT},
- {25.f, 25.f, PM_CIRC_60_OFT},
- {27.f, 27.f, PM_CIRC_65_OFT},
- {29.f, 29.f, PM_CIRC_70_OFT}}
-};
-
-static const Standard_Byte OpenGl_AspectMarker_myMarkerRaster[] =
-{
- // TYPE = PLUS
-
- 0x08,0x00,
- 0x08,0x00,
- 0x08,0x00,
- 0x08,0x00,
- 0xff,0x80,
- 0x08,0x00,
- 0x08,0x00,
- 0x08,0x00,
- 0x08,0x00, // PLUS 9x9 = 1.0
-
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00,
- 0xff,0xe0,
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00, // PLUS 11x11 = 1.5
-
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0xff,0xf8,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00, // PLUS 13x13 = 2.0
-
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0xff,0xfe,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00, // PLUS 15x15 = 2.5
-
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0xff,0xff, 0x80,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00, // PLUS 17x17 = 3.0
-
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0xff,0xff, 0xe0,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00, // PLUS 19x19 = 3.5
-
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0xff,0xff, 0xf8,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00, // PLUS 21x21 = 4.0
-
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0xff,0xff, 0xfe,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00, // PLUS 23x23 = 4.5
-
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0xff,0xff, 0xff,0x80,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00, // PLUS 25x25 = 5.0
-
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0xff,0xff, 0xff,0xe0,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x04, 0x00,0x00, // PLUS 27x27 = 5.5
-
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0xff,0xff, 0xff,0xf8,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00,
- 0x00,0x02, 0x00,0x00, // PLUS 29x29 = 6.0
-
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0xff,0xff, 0xff,0xfd,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00,
- 0x00,0x01, 0x00,0x00, // PLUS 31x31 = 6.5
-
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0xff,0xff, 0xff,0xff,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00, // PLUS 32x32 = 7.0
-
- // TYPE = STAR
-
- 0x10,
- 0x10,
- 0xd6,
- 0x38,
- 0x10,
- 0x38,
- 0xd6,
- 0x10,
- 0x10, // STAR 7x9 = 1.0
-
- 0x08,0x00,
- 0x08,0x00,
- 0x08,0x00,
- 0xc9,0x80,
- 0x3e,0x00,
- 0x08,0x00,
- 0x3e,0x00,
- 0xc9,0x80,
- 0x08,0x00,
- 0x08,0x00,
- 0x08,0x00, // STAR 9x11 = 1.5
-
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00,
- 0x84,0x20,
- 0x64,0xc0,
- 0x1f,0x00,
- 0x04,0x00,
- 0x1f,0x00,
- 0x64,0xc0,
- 0x84,0x20,
- 0x04,0x00,
- 0x04,0x00,
- 0x04,0x00, // STAR 11x13 = 2.0
-
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x82,0x18,
- 0x62,0x60,
- 0x1b,0x80,
- 0x06,0x00,
- 0x1b,0x80,
- 0x62,0x60,
- 0x82,0x18,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00, // STAR 13x15 = 2.5
-
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x82,0x08,
- 0x62,0x30,
- 0x12,0x40,
- 0x0f,0x80,
- 0x02,0x00,
- 0x0f,0x80,
- 0x12,0x40,
- 0x62,0x30,
- 0x82,0x08,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00,
- 0x02,0x00, // STAR 13x17 = 3.0
-
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0xc1,0x06,
- 0x21,0x18,
- 0x19,0x20,
- 0x07,0xc0,
- 0x01,0x00,
- 0x07,0xc0,
- 0x19,0x20,
- 0x21,0x18,
- 0xc1,0x06,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00,
- 0x01,0x00, // STAR 15x19 = 3.5
-
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x80,0x80, 0x80,
- 0x60,0x83, 0x00,
- 0x10,0x8c, 0x00,
- 0x0c,0x90, 0x00,
- 0x03,0xe0, 0x00,
- 0x00,0x80, 0x00,
- 0x03,0xe0, 0x00,
- 0x0c,0x90, 0x00,
- 0x10,0x8c, 0x00,
- 0x60,0x83, 0x00,
- 0x80,0x80, 0x80,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00,
- 0x00,0x80, 0x00, // STAR 17x21 = 4.0
-
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0xc0,0x40, 0x60,
- 0x30,0x41, 0x80,
- 0x08,0x42, 0x00,
- 0x06,0x4c, 0x00,
- 0x01,0xf0, 0x00,
- 0x00,0x40, 0x00,
- 0x01,0xf0, 0x00,
- 0x06,0x4c, 0x00,
- 0x08,0x42, 0x00,
- 0x30,0x41, 0x80,
- 0xc0,0x40, 0x60,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0x40, 0x00, // STAR 19x23 = 4.5
-
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x80,0x20, 0x08,
- 0x60,0x20, 0x30,
- 0x18,0x20, 0xc0,
- 0x04,0x21, 0x00,
- 0x03,0x26, 0x00,
- 0x00,0xf8, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0xf8, 0x00,
- 0x03,0x26, 0x00,
- 0x04,0x21, 0x00,
- 0x18,0x20, 0xc0,
- 0x60,0x20, 0x30,
- 0x80,0x20, 0x08,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x20, 0x00, // STAR 21x25 = 5.0
-
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0xc0,0x10, 0x06,
- 0x30,0x10, 0x18,
- 0x08,0x10, 0x60,
- 0x06,0x10, 0x80,
- 0x01,0x93, 0x00,
- 0x00,0x7c, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x7c, 0x00,
- 0x01,0x93, 0x00,
- 0x06,0x10, 0x80,
- 0x08,0x10, 0x60,
- 0x30,0x10, 0x18,
- 0xc0,0x10, 0x06,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x10, 0x00, // STAR 23x27 = 5.5
-
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x80,0x08, 0x00,0x80,
- 0x60,0x08, 0x03,0x00,
- 0x18,0x08, 0x0c,0x00,
- 0x04,0x08, 0x30,0x00,
- 0x03,0x08, 0x40,0x00,
- 0x00,0xc9, 0x80,0x00,
- 0x00,0x3e, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x3e, 0x00,0x00,
- 0x00,0xc9, 0x80,0x00,
- 0x03,0x08, 0x40,0x00,
- 0x04,0x08, 0x30,0x00,
- 0x18,0x08, 0x0c,0x00,
- 0x60,0x08, 0x03,0x00,
- 0x80,0x08, 0x00,0x80,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x08, 0x00,0x00, // STAR 25x29 = 6.0
-
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x30,0x00, 0x80,0x06,
- 0x0c,0x00, 0x80,0x18,
- 0x03,0x00, 0x80,0x60,
- 0x00,0xc0, 0x81,0x80,
- 0x00,0x30, 0x86,0x00,
- 0x00,0x0c, 0x98,0x00,
- 0x00,0x03, 0xe0,0x00,
- 0x00,0x03, 0xe0,0x00,
- 0x00,0x0c, 0x98,0x00,
- 0x00,0x30, 0x86,0x00,
- 0x00,0xc0, 0x81,0x80,
- 0x03,0x00, 0x80,0x60,
- 0x0c,0x00, 0x80,0x18,
- 0x30,0x00, 0x80,0x06,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x80,0x00,
- 0x00,0x00, 0x00,0x00,
- 0x00,0x00, 0x00,0x00, // STAR 32x32 = 6.5
-
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x10, 0x00, 0x80, 0x04,
- 0x0c, 0x00, 0x80, 0x18,
- 0x02, 0x00, 0x80, 0x20,
- 0x01, 0x80, 0x80, 0xc0,
- 0x00, 0x40, 0x81, 0x00,
- 0x00, 0x30, 0x86, 0x00,
- 0x00, 0x08, 0x88, 0x00,
- 0x00, 0x06, 0xb0, 0x00,
- 0x00, 0x01, 0xc0, 0x00,
- 0x00, 0x06, 0xb0, 0x00,
- 0x00, 0x08, 0x88, 0x00,
- 0x00, 0x30, 0x86, 0x00,
- 0x00, 0x40, 0x81, 0x00,
- 0x01, 0x80, 0x80, 0xc0,
- 0x02, 0x00, 0x80, 0x20,
- 0x0c, 0x00, 0x80, 0x18,
- 0x10, 0x00, 0x80, 0x04,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00,
- 0x00, 0x00, 0x80, 0x00, // STAR 32x32 = 7.0
-
- // TYPE = CIRC
-
- 0x38,
- 0x44,
- 0x82,
- 0x82,
- 0x82,
- 0x44,
- 0x38, // CIRC 7x7 = 1.0
-
- 0x3c,0x00,
- 0x42,0x00,
- 0x81,0x00,
- 0x81,0x00,
- 0x81,0x00,
- 0x81,0x00,
- 0x42,0x00,
- 0x3c,0x00,
- 0x00,0x00, //CIRC 9x9 = 1.5
-
- 0x3e,0x00,
- 0x41,0x00,
- 0x81,0x80,
- 0x80,0x80,
- 0x80,0x80,
- 0x80,0x80,
- 0x81,0x80,
- 0x41,0x00,
- 0x3e,0x00, // CIRC 9x9 = 2.0
-
- 0x1f,0x00,
- 0x20,0x80,
- 0x40,0x40,
- 0x80,0x20,
- 0x80,0x20,
- 0x80,0x20,
- 0x80,0x20,
- 0x80,0x20,
- 0x40,0x40,
- 0x20,0x80,
- 0x1f,0x00, // CIRC 11x11 = 2.5
-
- 0x0f,0x80,
- 0x10,0x40,
- 0x20,0x20,
- 0x40,0x10,
- 0x80,0x08,
- 0x80,0x08,
- 0x80,0x08,
- 0x80,0x08,
- 0x80,0x08,
- 0x40,0x10,
- 0x20,0x20,
- 0x10,0x40,
- 0x0f,0x80, // CIRC 13x13 = 3.0
-
- 0x07,0xc0,
- 0x18,0x30,
- 0x20,0x08,
- 0x40,0x04,
- 0x40,0x04,
- 0x80,0x02,
- 0x80,0x02,
- 0x80,0x02,
- 0x80,0x02,
- 0x80,0x02,
- 0x40,0x04,
- 0x40,0x04,
- 0x20,0x08,
- 0x18,0x30,
- 0x07,0xc0, // CIRC 15x15 = 3.5
-
- 0x03,0xe0, 0x00,
- 0x0c,0x18, 0x00,
- 0x10,0x04, 0x00,
- 0x20,0x02, 0x00,
- 0x40,0x01, 0x00,
- 0x40,0x01, 0x00,
- 0x80,0x00, 0x80,
- 0x80,0x00, 0x80,
- 0x80,0x00, 0x80,
- 0x80,0x00, 0x80,
- 0x80,0x00, 0x80,
- 0x40,0x01, 0x00,
- 0x40,0x01, 0x00,
- 0x20,0x02, 0x00,
- 0x10,0x04, 0x00,
- 0x0c,0x18, 0x00,
- 0x03,0xe0, 0x00, // CIRC 17x17 = 4.0
-
- 0x03,0xf8, 0x00,
- 0x0e,0x0e, 0x00,
- 0x18,0x03, 0x00,
- 0x20,0x00, 0x80,
- 0x60,0x00, 0xc0,
- 0x40,0x00, 0x40,
- 0xc0,0x00, 0x60,
- 0x80,0x00, 0x20,
- 0x80,0x00, 0x20,
- 0x80,0x00, 0x20,
- 0x80,0x00, 0x20,
- 0x80,0x00, 0x20,
- 0xc0,0x00, 0x60,
- 0x40,0x00, 0x40,
- 0x60,0x00, 0xc0,
- 0x20,0x00, 0x80,
- 0x18,0x03, 0x00,
- 0x0e,0x0e, 0x00,
- 0x03,0xf8, 0x00, // CIRC 19x19 = 4.5
-
- 0x01,0xfc, 0x00,
- 0x06,0x03, 0x00,
- 0x08,0x00, 0x80,
- 0x10,0x00, 0x40,
- 0x20,0x00, 0x20,
- 0x40,0x00, 0x10,
- 0x40,0x00, 0x10,
- 0x80,0x00, 0x08,
- 0x80,0x00, 0x08,
- 0x80,0x00, 0x08,
- 0x80,0x00, 0x08,
- 0x80,0x00, 0x08,
- 0x80,0x00, 0x08,
- 0x80,0x00, 0x08,
- 0x40,0x00, 0x10,
- 0x40,0x00, 0x10,
- 0x20,0x00, 0x20,
- 0x10,0x00, 0x40,
- 0x08,0x00, 0x80,
- 0x06,0x03, 0x00,
- 0x01,0xfc, 0x00, // CIRC 21x21 = 5.0
-
- 0x00,0xfe, 0x00,
- 0x03,0x01, 0x80,
- 0x0c,0x00, 0x60,
- 0x18,0x00, 0x30,
- 0x30,0x00, 0x18,
- 0x20,0x00, 0x08,
- 0x40,0x00, 0x04,
- 0x40,0x00, 0x04,
- 0x80,0x00, 0x02,
- 0x80,0x00, 0x02,
- 0x80,0x00, 0x02,
- 0x80,0x00, 0x02,
- 0x80,0x00, 0x02,
- 0x80,0x00, 0x02,
- 0x80,0x00, 0x02,
- 0x40,0x00, 0x04,
- 0x40,0x00, 0x04,
- 0x20,0x00, 0x08,
- 0x30,0x00, 0x18,
- 0x18,0x00, 0x30,
- 0x0c,0x00, 0x60,
- 0x03,0x01, 0x80,
- 0x00,0xfe, 0x00, // CIRC 23x23 = 5.5
-
- 0x00,0x7f, 0x00,0x00,
- 0x01,0x80, 0xc0,0x00,
- 0x06,0x00, 0x30,0x00,
- 0x08,0x00, 0x08,0x00,
- 0x10,0x00, 0x04,0x00,
- 0x20,0x00, 0x02,0x00,
- 0x20,0x00, 0x02,0x00,
- 0x40,0x00, 0x01,0x00,
- 0x40,0x00, 0x01,0x00,
- 0x80,0x00, 0x00,0x80,
- 0x80,0x00, 0x00,0x80,
- 0x80,0x00, 0x00,0x80,
- 0x80,0x00, 0x00,0x80,
- 0x80,0x00, 0x00,0x80,
- 0x80,0x00, 0x00,0x80,
- 0x80,0x00, 0x00,0x80,
- 0x40,0x00, 0x01,0x00,
- 0x40,0x00, 0x01,0x00,
- 0x20,0x00, 0x02,0x00,
- 0x20,0x00, 0x02,0x00,
- 0x10,0x00, 0x04,0x00,
- 0x08,0x00, 0x08,0x00,
- 0x06,0x00, 0x30,0x00,
- 0x01,0x80, 0xc0,0x00,
- 0x00,0x7f, 0x00,0x00, // CIRC 25x25 = 6.0
-
- 0x00,0x3f, 0x80,0x00,
- 0x01,0xc0, 0x70,0x00,
- 0x03,0x00, 0x18,0x00,
- 0x0c,0x00, 0x06,0x00,
- 0x18,0x00, 0x03,0x00,
- 0x10,0x00, 0x01,0x00,
- 0x20,0x00, 0x00,0x80,
- 0x60,0x00, 0x00,0xc0,
- 0x40,0x00, 0x00,0x40,
- 0x40,0x00, 0x00,0x40,
- 0x80,0x00, 0x00,0x20,
- 0x80,0x00, 0x00,0x20,
- 0x80,0x00, 0x00,0x20,
- 0x80,0x00, 0x00,0x20,
- 0x80,0x00, 0x00,0x20,
- 0x80,0x00, 0x00,0x20,
- 0x80,0x00, 0x00,0x20,
- 0x40,0x00, 0x00,0x40,
- 0x40,0x00, 0x00,0x40,
- 0x60,0x00, 0x00,0xc0,
- 0x20,0x00, 0x00,0x80,
- 0x10,0x00, 0x01,0x00,
- 0x18,0x00, 0x03,0x00,
- 0x0c,0x00, 0x06,0x00,
- 0x03,0x00, 0x18,0x00,
- 0x01,0xc0, 0x70,0x00,
- 0x00,0x3f, 0x80,0x00, // CIRC 27x27 = 6.5
-
- 0x00,0x1f, 0xc0,0x00,
- 0x00,0xe0, 0x38,0x00,
- 0x01,0x00, 0x04,0x00,
- 0x06,0x00, 0x03,0x00,
- 0x08,0x00, 0x00,0x80,
- 0x10,0x00, 0x00,0x40,
- 0x10,0x00, 0x00,0x40,
- 0x20,0x00, 0x00,0x20,
- 0x40,0x00, 0x00,0x10,
- 0x40,0x00, 0x00,0x10,
- 0x40,0x00, 0x00,0x10,
- 0x80,0x00, 0x00,0x08,
- 0x80,0x00, 0x00,0x08,
- 0x80,0x00, 0x00,0x08,
- 0x80,0x00, 0x00,0x08,
- 0x80,0x00, 0x00,0x08,
- 0x80,0x00, 0x00,0x08,
- 0x80,0x00, 0x00,0x08,
- 0x40,0x00, 0x00,0x10,
- 0x40,0x00, 0x00,0x10,
- 0x40,0x00, 0x00,0x10,
- 0x20,0x00, 0x00,0x20,
- 0x10,0x00, 0x00,0x40,
- 0x10,0x00, 0x00,0x40,
- 0x08,0x00, 0x00,0x80,
- 0x06,0x00, 0x03,0x00,
- 0x01,0x00, 0x04,0x00,
- 0x00,0xe0, 0x38,0x00,
- 0x00,0x1f, 0xc0,0x00, // CIRC 29x29 = 7.0
-
- // TYPE = CROSS
-
- 0x82,
- 0x44,
- 0x28,
- 0x10,
- 0x28,
- 0x44,
- 0x82, // CROSS 7x7 = 1.0
-
- 0x80,0x80,
- 0x41,0x00,
- 0x22,0x00,
- 0x14,0x00,
- 0x08,0x00,
- 0x14,0x00,
- 0x22,0x00,
- 0x41,0x00,
- 0x80,0x80, // CROSS 9x9 = 1.5
-
- 0x80,0x20,
- 0x40,0x40,
- 0x20,0x80,
- 0x11,0x00,
- 0x0a,0x00,
- 0x04,0x00,
- 0x0a,0x00,
- 0x11,0x00,
- 0x20,0x80,
- 0x40,0x40,
- 0x80,0x20, // CROSS 11x11 = 2.0
-
- 0x80,0x08,
- 0x40,0x10,
- 0x20,0x20,
- 0x10,0x40,
- 0x08,0x80,
- 0x05,0x00,
- 0x02,0x00,
- 0x05,0x00,
- 0x08,0x80,
- 0x10,0x40,
- 0x20,0x20,
- 0x40,0x10,
- 0x80,0x08, // CROSS 13x13 = 2.5
-
- 0x80,0x02,
- 0x40,0x04,
- 0x20,0x08,
- 0x10,0x10,
- 0x08,0x20,
- 0x04,0x40,
- 0x02,0x80,
- 0x01,0x00,
- 0x02,0x80,
- 0x04,0x40,
- 0x08,0x20,
- 0x10,0x10,
- 0x20,0x08,
- 0x40,0x04,
- 0x80,0x02, // CROSS 15x15 = 3.0
-
- 0x80,0x00, 0x80,
- 0x40,0x01, 0x00,
- 0x20,0x02, 0x00,
- 0x10,0x04, 0x00,
- 0x08,0x08, 0x00,
- 0x04,0x10, 0x00,
- 0x02,0x20, 0x00,
- 0x01,0x40, 0x00,
- 0x00,0x80, 0x00,
- 0x01,0x40, 0x00,
- 0x02,0x20, 0x00,
- 0x04,0x10, 0x00,
- 0x08,0x08, 0x00,
- 0x10,0x04, 0x00,
- 0x20,0x02, 0x00,
- 0x40,0x01, 0x00,
- 0x80,0x00, 0x80, // CROSS 17x17 = 3.5
-
- 0x80,0x00, 0x20,
- 0x40,0x00, 0x40,
- 0x20,0x00, 0x80,
- 0x10,0x01, 0x00,
- 0x08,0x02, 0x00,
- 0x04,0x04, 0x00,
- 0x02,0x08, 0x00,
- 0x01,0x10, 0x00,
- 0x00,0xa0, 0x00,
- 0x00,0x40, 0x00,
- 0x00,0xa0, 0x00,
- 0x01,0x10, 0x00,
- 0x02,0x08, 0x00,
- 0x04,0x04, 0x00,
- 0x08,0x02, 0x00,
- 0x10,0x01, 0x00,
- 0x20,0x00, 0x80,
- 0x40,0x00, 0x40,
- 0x80,0x00, 0x20, // CROSS 19x19 = 4.0
-
- 0x80,0x00, 0x08,
- 0x40,0x00, 0x10,
- 0x20,0x00, 0x20,
- 0x10,0x00, 0x40,
- 0x08,0x00, 0x80,
- 0x04,0x01, 0x00,
- 0x02,0x02, 0x00,
- 0x01,0x04, 0x00,
- 0x00,0x88, 0x00,
- 0x00,0x50, 0x00,
- 0x00,0x20, 0x00,
- 0x00,0x50, 0x00,
- 0x00,0x88, 0x00,
- 0x01,0x04, 0x00,
- 0x02,0x02, 0x00,
- 0x04,0x01, 0x00,
- 0x08,0x00, 0x80,
- 0x10,0x00, 0x40,
- 0x20,0x00, 0x20,
- 0x40,0x00, 0x10,
- 0x80,0x00, 0x08,/* CROSS 21x21 = 4.5 */
-
- 0x80,0x00, 0x02,
- 0x40,0x00, 0x04,
- 0x20,0x00, 0x08,
- 0x10,0x00, 0x10,
- 0x08,0x00, 0x20,
- 0x04,0x00, 0x40,
- 0x02,0x00, 0x80,
- 0x01,0x01, 0x00,
- 0x00,0x82, 0x00,
- 0x00,0x44, 0x00,
- 0x00,0x28, 0x00,
- 0x00,0x10, 0x00,
- 0x00,0x28, 0x00,
- 0x00,0x44, 0x00,
- 0x00,0x82, 0x00,
- 0x01,0x01, 0x00,
- 0x02,0x00, 0x80,
- 0x04,0x00, 0x40,
- 0x08,0x00, 0x20,
- 0x10,0x00, 0x10,
- 0x20,0x00, 0x08,
- 0x40,0x00, 0x04,
- 0x80,0x00, 0x02, // CROSS 23x23 = 5.0
-
- 0x80,0x00, 0x00,0x80,
- 0x40,0x00, 0x01,0x00,
- 0x20,0x00, 0x02,0x00,
- 0x10,0x00, 0x04,0x00,
- 0x08,0x00, 0x08,0x00,
- 0x04,0x00, 0x10,0x00,
- 0x02,0x00, 0x20,0x00,
- 0x01,0x00, 0x40,0x00,
- 0x00,0x80, 0x80,0x00,
- 0x00,0x41, 0x00,0x00,
- 0x00,0x22, 0x00,0x00,
- 0x00,0x14, 0x00,0x00,
- 0x00,0x08, 0x00,0x00,
- 0x00,0x14, 0x00,0x00,
- 0x00,0x22, 0x00,0x00,
- 0x00,0x41, 0x00,0x00,
- 0x00,0x80, 0x80,0x00,
- 0x01,0x00, 0x40,0x00,
- 0x02,0x00, 0x20,0x00,
- 0x04,0x00, 0x10,0x00,
- 0x08,0x00, 0x08,0x00,
- 0x10,0x00, 0x04,0x00,
- 0x20,0x00, 0x02,0x00,
- 0x40,0x00, 0x01,0x00,
- 0x80,0x00, 0x00,0x80, // CROSS 25x25 = 5.5
-
- 0x80,0x00, 0x00,0x20,
- 0x40,0x00, 0x00,0x40,
- 0x20,0x00, 0x00,0x80,
- 0x10,0x00, 0x01,0x00,
- 0x08,0x00, 0x02,0x00,
- 0x04,0x00, 0x04,0x00,
- 0x02,0x00, 0x08,0x00,
- 0x01,0x00, 0x10,0x00,
- 0x00,0x80, 0x20,0x00,
- 0x00,0x40, 0x40,0x00,
- 0x00,0x20, 0x80,0x00,
- 0x00,0x11, 0x00,0x00,
- 0x00,0x0a, 0x00,0x00,
- 0x00,0x04, 0x00,0x00,
- 0x00,0x0a, 0x00,0x00,
- 0x00,0x11, 0x00,0x00,
- 0x00,0x20, 0x80,0x00,
- 0x00,0x40, 0x40,0x00,
- 0x00,0x80, 0x20,0x00,
- 0x01,0x00, 0x10,0x00,
- 0x02,0x00, 0x08,0x00,
- 0x04,0x00, 0x04,0x00,
- 0x08,0x00, 0x02,0x00,
- 0x10,0x00, 0x01,0x00,
- 0x20,0x00, 0x00,0x80,
- 0x40,0x00, 0x00,0x40,
- 0x80,0x00, 0x00,0x20, // CROSS 27x27 = 6.0
-
- 0x00,0x00, 0x00,0x00,
- 0x00,0x00, 0x00,0x00,
- 0x20,0x00, 0x00,0x04,
- 0x10,0x00, 0x00,0x08,
- 0x08,0x00, 0x00,0x10,
- 0x04,0x00, 0x00,0x20,
- 0x02,0x00, 0x00,0x40,
- 0x01,0x00, 0x00,0x80,
- 0x00,0x80, 0x01,0x00,
- 0x00,0x40, 0x02,0x00,
- 0x00,0x20, 0x04,0x00,
- 0x00,0x10, 0x08,0x00,
- 0x00,0x08, 0x10,0x00,
- 0x00,0x04, 0x20,0x00,
- 0x00,0x02, 0x40,0x00,
- 0x00,0x01, 0x80,0x00,
- 0x00,0x01, 0x80,0x00,
- 0x00,0x02, 0x40,0x00,
- 0x00,0x04, 0x20,0x00,
- 0x00,0x08, 0x10,0x00,
- 0x00,0x10, 0x08,0x00,
- 0x00,0x20, 0x04,0x00,
- 0x00,0x40, 0x02,0x00,
- 0x00,0x80, 0x01,0x00,
- 0x01,0x00, 0x00,0x80,
- 0x02,0x00, 0x00,0x40,
- 0x04,0x00, 0x00,0x20,
- 0x08,0x00, 0x00,0x10,
- 0x10,0x00, 0x00,0x08,
- 0x20,0x00, 0x00,0x04,
- 0x00,0x00, 0x00,0x00,
- 0x00,0x00, 0x00,0x00, // CROSS 32x32 = 6.5
-
- 0x00,0x00, 0x00,0x00,
- 0x40,0x00, 0x00,0x02,
- 0x20,0x00, 0x00,0x04,
- 0x10,0x00, 0x00,0x08,
- 0x08,0x00, 0x00,0x10,
- 0x04,0x00, 0x00,0x20,
- 0x02,0x00, 0x00,0x40,
- 0x01,0x00, 0x00,0x80,
- 0x00,0x80, 0x01,0x00,
- 0x00,0x40, 0x02,0x00,
- 0x00,0x20, 0x04,0x00,
- 0x00,0x10, 0x08,0x00,
- 0x00,0x08, 0x10,0x00,
- 0x00,0x04, 0x20,0x00,
- 0x00,0x02, 0x40,0x00,
- 0x00,0x01, 0x80,0x00,
- 0x00,0x01, 0x80,0x00,
- 0x00,0x02, 0x40,0x00,
- 0x00,0x04, 0x20,0x00,
- 0x00,0x08, 0x10,0x00,
- 0x00,0x10, 0x08,0x00,
- 0x00,0x20, 0x04,0x00,
- 0x00,0x40, 0x02,0x00,
- 0x00,0x80, 0x01,0x00,
- 0x01,0x00, 0x00,0x80,
- 0x02,0x00, 0x00,0x40,
- 0x04,0x00, 0x00,0x20,
- 0x08,0x00, 0x00,0x10,
- 0x10,0x00, 0x00,0x08,
- 0x20,0x00, 0x00,0x04,
- 0x40,0x00, 0x00,0x02,
- 0x00,0x00, 0x00,0x00 // CROSS 32x32 = 7.0
-};
-
-// =======================================================================
-// function : GetMarkerBitMapArray
-// purpose : Returns a parameters for the marker of the specified
-// type and scale.
-// =======================================================================
-void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
- const Standard_ShortReal& theScale,
- Standard_Integer& theWidth,
- Standard_Integer& theHeight,
- Standard_Integer& theOffset,
- Standard_Integer& theNumOfBytes)
-{
- const Standard_Integer aType = (Standard_Integer )((theMarkerType > Aspect_TOM_O) ? Aspect_TOM_O : theMarkerType);
- const Standard_Real anIndex = (Standard_Real )(TEL_NO_OF_SIZES - 1) * (theScale - (Standard_Real )TEL_PM_START_SIZE)
- / (Standard_Real )(TEL_PM_END_SIZE - TEL_PM_START_SIZE);
- Standard_Integer anId = (Standard_Integer )(anIndex + 0.5);
- if (anId < 0)
- {
- anId = 0;
- }
- else if (anId >= TEL_NO_OF_SIZES)
- {
- anId = TEL_NO_OF_SIZES - 1;
- }
-
- theWidth = (Standard_Integer )arrPMFontInfo[aType][anId].width;
- theHeight = (Standard_Integer )arrPMFontInfo[aType][anId].height;
- theOffset = arrPMFontInfo[aType][anId].offset;
- const Standard_Integer aNumOfBytesInRow = theWidth / 8 + (theWidth % 8 ? 1 : 0);
- theNumOfBytes = theHeight * aNumOfBytesInRow;
-}
-
-// =======================================================================
-// function : GetTextureImage
-// purpose : Returns a marker image for the marker of the specified
-// type and scale.
-// =======================================================================
-Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
- const Standard_ShortReal& theScale)
-{
- Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
- GetMarkerBitMapParam (theMarkerType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
-
- Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
- for (Standard_Integer anIter = 0; anIter < aNumOfBytes; anIter++)
- {
- aBitMap->ChangeValue (anIter) = OpenGl_AspectMarker_myMarkerRaster[anOffset + anIter];
- }
-
- Handle(Graphic3d_MarkerImage) aTexture = new Graphic3d_MarkerImage (aBitMap, aWidth, aHeight);
- return aTexture;
-}
-
-// =======================================================================
-// function : MergeImages
-// purpose : Merge two image pixmap into one. Used for creating image for
-// following markers: Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS,
-// Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1,
-// Aspect_TOM_RING2, Aspect_TOM_RING3
-// =======================================================================
-Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
- const Handle(Image_PixMap)& theImage2)
-{
- if (theImage1.IsNull() && theImage2.IsNull())
- {
- return Handle(Image_PixMap)();
- }
-
- Handle(Image_PixMap) aResultImage = new Image_PixMap();
-
- Standard_Integer aWidth1 (0), aHeight1 (0);
- if (!theImage1.IsNull())
- {
- aWidth1 = (Standard_Integer )theImage1->Width();
- aHeight1 = (Standard_Integer )theImage1->Height();
- }
-
- Standard_Integer aWidth2 (0), aHeight2 (0);
- if (!theImage2.IsNull())
- {
- aWidth2 = (Standard_Integer )theImage2->Width();
- aHeight2 = (Standard_Integer )theImage2->Height();
- }
-
- const Standard_Integer aMaxWidth = Max (aWidth1, aWidth2);
- const Standard_Integer aMaxHeight = Max (aHeight1, aHeight2);
- const Standard_Integer aSize = Max (aMaxWidth, aMaxHeight);
-
- aResultImage->InitZero (Image_Format_Alpha, aSize, aSize);
-
- if (!theImage1.IsNull())
- {
- const Standard_Integer aXOffset1 = Abs (aWidth1 - aMaxWidth) / 2;
- const Standard_Integer anYOffset1 = Abs (aHeight1 - aMaxHeight) / 2;
- for (Standard_Integer anY = 0; anY < aHeight1; anY++)
- {
- Standard_Byte* anImageLine = theImage1->ChangeRow (anY);
- Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset1 + anY);
- for (Standard_Integer aX = 0; aX < aWidth1; aX++)
- {
- aResultImageLine[aXOffset1 + aX] |= anImageLine[aX];
- }
- }
- }
-
- if (!theImage2.IsNull())
- {
- const Standard_Integer aXOffset2 = Abs (aWidth2 - aMaxWidth) / 2;
- const Standard_Integer anYOffset2 = Abs (aHeight2 - aMaxHeight) / 2;
- for (Standard_Integer anY = 0; anY < aHeight2; anY++)
- {
- Standard_Byte* anImageLine = theImage2->ChangeRow (anY);
- Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset2 + anY);
- for (Standard_Integer aX = 0; aX < aWidth2; aX++)
- {
- aResultImageLine[aXOffset2 + aX] |= anImageLine[aX];
- }
- }
- }
-
- return aResultImage;
-}
-
-// =======================================================================
-// function : OpenGl_AspectMarker
-// purpose :
-// =======================================================================
-OpenGl_AspectMarker::OpenGl_AspectMarker()
-: myAspect (new Graphic3d_AspectMarker3d (Aspect_TOM_PLUS, Quantity_Color (Quantity_NOC_WHITE), 1.0f)),
- myMarkerSize (1.0f)
-{
- //
-}
-
-// =======================================================================
-// function : OpenGl_AspectMarker
-// purpose :
-// =======================================================================
-OpenGl_AspectMarker::OpenGl_AspectMarker (const Handle(Graphic3d_AspectMarker3d)& theAspect)
-: myMarkerSize (1.0f)
-{
- SetAspect (theAspect);
-}
-
-// =======================================================================
-// function : SetAspect
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect)
-{
- myAspect = theAspect;
-
- // update resource bindings
- myResources.UpdateTexturesRediness (theAspect, myMarkerSize);
- myResources.UpdateShaderRediness (theAspect);
-}
-
-// =======================================================================
-// function : Render
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
-{
- theWorkspace->SetAspectMarker (this);
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Release (OpenGl_Context* theCtx)
-{
- myResources.ReleaseTextures(theCtx);
- myResources.ReleaseShaders (theCtx);
-}
-
-// =======================================================================
-// function : ReleaseTextures
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::ReleaseTextures (OpenGl_Context* theCtx)
-{
- myIsSpriteReady = Standard_False;
- if (mySprite.IsNull())
- {
- return;
- }
-
- if (theCtx != NULL)
- {
- if (mySprite->First()->ResourceId().IsEmpty())
- {
- theCtx->DelayedRelease (mySprite->ChangeFirst());
- theCtx->DelayedRelease (mySpriteA->ChangeFirst());
- }
- else
- {
- {
- const TCollection_AsciiString aSpriteKey = mySprite->First()->ResourceId();
- mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
- theCtx->ReleaseResource (aSpriteKey, Standard_True);
- }
- if (!mySpriteA.IsNull())
- {
- const TCollection_AsciiString aSpriteKeyA = mySpriteA->First()->ResourceId();
- mySpriteA.Nullify();
- theCtx->ReleaseResource (aSpriteKeyA, Standard_True);
- }
- }
- }
- mySprite.Nullify();
- mySpriteA.Nullify();
-}
-
-// =======================================================================
-// function : ReleaseShaders
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::ReleaseShaders (OpenGl_Context* theCtx)
-{
- if (!myShaderProgram.IsNull() && theCtx != NULL)
- {
- theCtx->ShaderManager()->Unregister (myShaderProgramId,
- myShaderProgram);
- }
- myShaderProgramId.Clear();
- myIsShaderReady = Standard_False;
-}
-
-// =======================================================================
-// function : UpdateTexturesRediness
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::UpdateTexturesRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect,
- Standard_ShortReal& theMarkerSize)
-{
- // update sprite resource bindings
- TCollection_AsciiString aSpriteKeyNew, aSpriteAKeyNew;
- spriteKeys (theAspect->GetMarkerImage(), theAspect->Type(), theAspect->Scale(), theAspect->ColorRGBA(), aSpriteKeyNew, aSpriteAKeyNew);
- const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
- const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
- if (aSpriteKeyNew.IsEmpty() || aSpriteKeyOld != aSpriteKeyNew
- || aSpriteAKeyNew.IsEmpty() || aSpriteAKeyOld != aSpriteAKeyNew)
- {
- myIsSpriteReady = Standard_False;
- theMarkerSize = theAspect->Scale();
- }
-}
-
-// =======================================================================
-// function : UpdateShaderRediness
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::UpdateShaderRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect)
-{
- // update shader program resource bindings
- const TCollection_AsciiString& aShaderKey = theAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : theAspect->ShaderProgram()->GetId();
- if (aShaderKey.IsEmpty() || myShaderProgramId != aShaderKey)
- {
- myIsShaderReady = Standard_False;
- }
-}
-
-// =======================================================================
-// function : BuildSprites
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::BuildSprites (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_MarkerImage)& theMarkerImage,
- const Aspect_TypeOfMarker theType,
- const Standard_ShortReal theScale,
- const Graphic3d_Vec4& theColor,
- Standard_ShortReal& theMarkerSize)
-{
- // generate key for shared resource
- TCollection_AsciiString aNewKey, aNewKeyA;
- spriteKeys (theMarkerImage, theType, theScale, theColor, aNewKey, aNewKeyA);
-
- const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
- const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
-
- // release old shared resources
- const Standard_Boolean aNewResource = aNewKey.IsEmpty()
- || aSpriteKeyOld != aNewKey;
- if (aNewResource)
- {
- if (!mySprite.IsNull())
- {
- if (mySprite->First()->ResourceId().IsEmpty())
- {
- theCtx->DelayedRelease (mySprite->ChangeFirst());
- mySprite.Nullify();
- }
- else
- {
- const TCollection_AsciiString anOldKey = mySprite->First()->ResourceId();
- mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
- theCtx->ReleaseResource (anOldKey, Standard_True);
- }
- }
- }
- if (aNewKeyA.IsEmpty() || aSpriteAKeyOld != aNewKeyA)
- {
- if (!mySpriteA.IsNull())
- {
- if (mySpriteA->First()->ResourceId().IsEmpty())
- {
- theCtx->DelayedRelease (mySpriteA->ChangeFirst());
- mySpriteA.Nullify();
- }
- else
- {
- const TCollection_AsciiString anOldKey = mySpriteA->First()->ResourceId();
- mySpriteA.Nullify(); // we need nullify all handles before ReleaseResource() call
- theCtx->ReleaseResource (anOldKey, Standard_True);
- }
- }
- }
-
- if (!aNewResource)
- {
- const OpenGl_PointSprite* aSprite = dynamic_cast<OpenGl_PointSprite*> (mySprite->First().get());
- if (!aSprite->IsDisplayList())
- {
- theMarkerSize = Standard_ShortReal (Max (aSprite->SizeX(), aSprite->SizeY()));
- }
- return;
- }
- if (theType == Aspect_TOM_POINT
- || theType == Aspect_TOM_EMPTY
- || (theType == Aspect_TOM_USERDEFINED && theMarkerImage.IsNull()))
- {
- // nothing to do - just simple point
- return;
- }
-
- if (mySprite.IsNull())
- {
- mySprite = new OpenGl_TextureSet (1);
- mySpriteA = new OpenGl_TextureSet (1);
- }
-
- Handle(OpenGl_PointSprite) aSprite, aSpriteA;
- if (!aNewKey.IsEmpty()
- && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, aSpriteA) // alpha sprite could be shared
- && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, aSprite))
- {
- // reuse shared resource
- if (!aSprite->IsDisplayList())
- {
- theMarkerSize = Standard_ShortReal (Max (aSprite->SizeX(), aSprite->SizeY()));
- }
- mySprite ->ChangeFirst() = aSprite;
- mySpriteA->ChangeFirst() = aSpriteA;
- return;
- }
-
- const bool hadAlreadyAlpha = !aSpriteA.IsNull();
- if (!hadAlreadyAlpha)
- {
- aSpriteA = new OpenGl_PointSprite (aNewKeyA);
- }
- aSprite = new OpenGl_PointSprite (aNewKey);
- mySprite ->ChangeFirst() = aSprite;
- mySpriteA->ChangeFirst() = aSpriteA;
- if (!aNewKey.IsEmpty())
- {
- theCtx->ShareResource (aNewKey, aSprite);
- if (!hadAlreadyAlpha)
- {
- theCtx->ShareResource (aNewKeyA, aSpriteA);
- }
- }
-
- if (!theCtx.IsNull()
- && theCtx->core20fwd != NULL
- && !theCtx->caps->pntSpritesDisable)
- {
- // Creating texture resource for using it with point sprites
- Handle(Graphic3d_MarkerImage) aNewMarkerImage;
- Handle(Image_PixMap) anImage, anImageA;
-
- if (theType == Aspect_TOM_USERDEFINED && !theMarkerImage.IsNull())
- {
- aNewMarkerImage = theMarkerImage;
- anImage = aNewMarkerImage->GetImage();
- }
- else
- {
- // Creating image from default bitmap
- Handle(Graphic3d_MarkerImage) aMarkerImage1, aMarkerImage2;
-
- const Standard_ShortReal aDelta = 0.1F;
- Standard_ShortReal aScale = theScale;
- Standard_ShortReal aLimit = 0.0F;
-
- switch (theType)
- {
- case Aspect_TOM_O_POINT:
- {
- // draw inner point as filled rectangle
- const Standard_Integer aSize = theScale > 7 ? 7 : (Standard_Integer )(theScale + 0.5F);
- Handle(TColStd_HArray1OfByte) aBitMap = fillPointBitmap (aSize);
- aMarkerImage2 = new Graphic3d_MarkerImage (aBitMap, aSize, aSize);
- }
- Standard_FALLTHROUGH
- case Aspect_TOM_O_PLUS:
- case Aspect_TOM_O_STAR:
- case Aspect_TOM_O_X:
- {
- // For this type of markers we merge two base bitmaps into one
- // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
- aMarkerImage1 = GetTextureImage (Aspect_TOM_O, theScale);
- if (theType != Aspect_TOM_O_POINT)
- {
- aMarkerImage2 = GetTextureImage (Aspect_TypeOfMarker (theType - Aspect_TOM_O_POINT), theScale);
- }
- anImage = MergeImages (aMarkerImage1->GetImage(), aMarkerImage2->GetImage());
- aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
- break;
- }
- case Aspect_TOM_RING1:
- if (aLimit == 0.0f) aLimit = aScale * 0.2f;
- Standard_FALLTHROUGH
- case Aspect_TOM_RING2:
- if (aLimit == 0.0f) aLimit = aScale * 0.5f;
- Standard_FALLTHROUGH
- case Aspect_TOM_RING3:
- {
- if (aLimit == 0.0f) aLimit = aScale * 0.8f;
- for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
- {
- anImage = MergeImages (anImage, GetTextureImage (Aspect_TOM_O, aScale)->GetImage());
- }
- aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
- break;
- }
- case Aspect_TOM_BALL:
- {
- Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
- GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
-
- NCollection_Vec4<Standard_Real> aColor (Standard_Real (theColor.r()),
- Standard_Real (theColor.g()),
- Standard_Real (theColor.b()),
- Standard_Real (theColor.a()));
-
- const Standard_Integer aSize = Max (aWidth + 2, aHeight + 2); // includes extra margin
- anImage = new Image_PixMap();
- anImageA = new Image_PixMap();
- anImage ->InitZero (Image_Format_BGRA, aSize, aSize);
- anImageA->InitZero (Image_Format_Alpha, aSize, aSize);
-
- // we draw a set of circles
- Image_ColorBGRA aColor32;
- aColor32.a() = 255;
- Standard_Real aHLS[3];
- while (aScale >= 1.0f)
- {
- Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
- aHLS[2] *= 0.95; // 5% saturation change
- Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
- aColor32.r() = Standard_Byte(255.0 * aColor.r());
- aColor32.g() = Standard_Byte(255.0 * aColor.g());
- aColor32.b() = Standard_Byte(255.0 * aColor.b());
-
- const Handle(Graphic3d_MarkerImage) aMarker = GetTextureImage (Aspect_TOM_O, aScale);
- const Handle(Image_PixMap)& aCircle = aMarker->GetImage();
-
- const Standard_Size aDiffX = (anImage->SizeX() - aCircle->SizeX()) / 2;
- const Standard_Size aDiffY = (anImage->SizeY() - aCircle->SizeY()) / 2;
- for (Standard_Size aRow = 0; aRow < aCircle->SizeY(); ++aRow)
- {
- const Standard_Byte* aRowData = aCircle->Row (aRow);
- for (Standard_Size aCol = 0; aCol < aCircle->SizeX(); ++aCol)
- {
- if (aRowData[aCol] != 0)
- {
- anImage ->ChangeValue<Image_ColorBGRA> (aDiffX + aRow, aDiffY + aCol) = aColor32;
- anImageA->ChangeValue<Standard_Byte> (aDiffX + aRow, aDiffY + aCol) = 255;
- }
- }
- }
- aScale -= aDelta;
- }
- break;
- }
- default:
- {
- aNewMarkerImage = GetTextureImage (theType, theScale);
- anImage = aNewMarkerImage->GetImage();
- break;
- }
- }
- }
-
- theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
-
- aSprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
- if (!hadAlreadyAlpha)
- {
- if (anImageA.IsNull()
- && aSprite->GetFormat() != GL_ALPHA
- && !aNewMarkerImage.IsNull())
- {
- anImageA = aNewMarkerImage->GetImageAlpha();
- }
- if (!anImageA.IsNull())
- {
- aSpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
- }
- }
- }
- else
- {
- #if !defined(GL_ES_VERSION_2_0)
- // Creating list with bitmap for using it in compatibility mode
- GLuint aBitmapList = glGenLists (1);
- aSprite->SetDisplayList (theCtx, aBitmapList);
-
- Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
- if (theType == Aspect_TOM_USERDEFINED && !theMarkerImage.IsNull())
- {
- // Reading user defined marker
- Handle(TColStd_HArray1OfByte) aBitMap = theMarkerImage->GetBitMapArray();
- Standard_Byte* aBitMapArray = new Standard_Byte[aBitMap->Length()];
- theMarkerImage->GetTextureSize (aWidth, aHeight);
-
- // We should pass bitmap to glBitmap with reversed line order as it draws it from
- // bottom to top
- const Standard_Integer aNumOfBytesInRow = aWidth / 8 + (aWidth % 8 ? 1 : 0);
- const Standard_Integer anUpperIndex = aBitMap->Upper();
- for (Standard_Integer aRow = 0; aRow < aHeight; aRow++)
- {
- for (Standard_Integer aByteIter = 0; aByteIter < aNumOfBytesInRow; aByteIter++)
- {
- aBitMapArray[aRow * aNumOfBytesInRow + aByteIter] =
- aBitMap->Value (anUpperIndex + 1 - (aRow + 1) * aNumOfBytesInRow + aByteIter);
- }
- }
-
- if (aBitMapArray != NULL)
- {
- glNewList (aBitmapList, GL_COMPILE);
- glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
- 0.f, 0.f, (const GLubyte* )aBitMapArray);
- glEndList();
- }
- }
- else
- {
- // Creating list for default marker
- const Standard_ShortReal aDelta = 0.1f;
- Standard_ShortReal aScale = theScale;
- Standard_ShortReal aLimit = 0.0f;
-
- glNewList (aBitmapList, GL_COMPILE);
- switch (theType)
- {
- case Aspect_TOM_O_POINT:
- {
- // draw inner point as filled rectangle
- const Standard_Integer aSize = theScale > 7 ? 7 : (Standard_Integer )(theScale + 0.5F);
- Handle(TColStd_HArray1OfByte) aBitMap = fillPointBitmap (aSize);
- glBitmap (aSize, aSize, (GLfloat )(0.5f * aSize), (GLfloat )(0.5f * aSize),
- 0.0f, 0.0f, &aBitMap->Array1().Value (aBitMap->Lower()));
- }
- Standard_FALLTHROUGH
- case Aspect_TOM_O_PLUS:
- case Aspect_TOM_O_STAR:
- case Aspect_TOM_O_X:
- {
- // For this type of markers we merge two base bitmaps into one
- // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
- GetMarkerBitMapParam (Aspect_TOM_O, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
- glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
- 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
- if (theType != Aspect_TOM_O_POINT)
- {
- GetMarkerBitMapParam (Aspect_TypeOfMarker (theType - Aspect_TOM_O_POINT), theScale, aWidth, aHeight, anOffset, aNumOfBytes);
- glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
- 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
- }
- break;
- }
- case Aspect_TOM_BALL:
- {
- NCollection_Vec4<Standard_Real> aColor (Standard_Real (theColor.r()),
- Standard_Real (theColor.g()),
- Standard_Real (theColor.b()),
- Standard_Real (theColor.a()));
-
- // we draw a set of circles
- while (aScale >= 1.0f)
- {
- Standard_Real aHLS[3];
- Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
- // 5% saturation change
- aHLS[2] *= 0.95;
- Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
-
- glColor4dv (aColor);
- GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
- glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
- 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
-
- aScale -= aDelta;
- }
- break;
- }
- case Aspect_TOM_RING1:
- if (aLimit == 0.0f) aLimit = aScale * 0.2f;
- Standard_FALLTHROUGH
- case Aspect_TOM_RING2:
- if (aLimit == 0.0f) aLimit = aScale * 0.5f;
- Standard_FALLTHROUGH
- case Aspect_TOM_RING3:
- {
- if (aLimit == 0.0f) aLimit = aScale * 0.8f;
- for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
- {
- GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
- glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
- 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
- }
- break;
- }
- default:
- {
- GetMarkerBitMapParam (theType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
- glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
- 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
- break;
- }
- }
- glEndList();
- }
- #endif
- }
-}
-
-// =======================================================================
-// function : BuildShader
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader)
-{
- if (theCtx->core20fwd == NULL)
- {
- return;
- }
-
- // release old shader program resources
- if (!myShaderProgram.IsNull())
- {
- theCtx->ShaderManager()->Unregister (myShaderProgramId, myShaderProgram);
- myShaderProgramId.Clear();
- myShaderProgram.Nullify();
- }
- if (theShader.IsNull())
- {
- return;
- }
-
- theCtx->ShaderManager()->Create (theShader, myShaderProgramId, myShaderProgram);
-}
-
-// =======================================================================
-// function : spriteKeys
-// purpose :
-// =======================================================================
-void OpenGl_AspectMarker::Resources::spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
- const Aspect_TypeOfMarker theType,
- const Standard_ShortReal theScale,
- const Graphic3d_Vec4& theColor,
- TCollection_AsciiString& theKey,
- TCollection_AsciiString& theKeyA)
-{
- // generate key for shared resource
- if (theType == Aspect_TOM_USERDEFINED)
- {
- if (!theMarkerImage.IsNull())
- {
- theKey = theMarkerImage->GetImageId();
- theKeyA = theMarkerImage->GetImageAlphaId();
- }
- }
- else if (theType != Aspect_TOM_POINT
- && theType != Aspect_TOM_EMPTY)
- {
- // predefined markers are defined with 0.5 step
- const Standard_Integer aScale = Standard_Integer(theScale * 10.0f + 0.5f);
- theKey = TCollection_AsciiString ("OpenGl_AspectMarker") + theType + "_" + aScale;
- theKeyA = theKey + "A";
- if (theType == Aspect_TOM_BALL)
- {
- unsigned int aColor[3] =
- {
- (unsigned int )(255.0f * theColor.r()),
- (unsigned int )(255.0f * theColor.g()),
- (unsigned int )(255.0f * theColor.b())
- };
- char aBytes[8];
- sprintf (aBytes, "%02X%02X%02X", aColor[0], aColor[1], aColor[2]);
- theKey += aBytes;
- }
- }
-}
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2014 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 OpenGl_AspectMarker_Header
-#define OpenGl_AspectMarker_Header
-
-#include <Aspect_TypeOfMarker.hxx>
-#include <Graphic3d_AspectMarker3d.hxx>
-#include <TCollection_AsciiString.hxx>
-
-#include <OpenGl_Element.hxx>
-#include <OpenGl_TextureSet.hxx>
-
-class OpenGl_PointSprite;
-class OpenGl_ShaderProgram;
-
-//! The element holding Graphic3d_AspectMarker3d.
-class OpenGl_AspectMarker : public OpenGl_Element
-{
-public:
-
- //! Empty constructor.
- Standard_EXPORT OpenGl_AspectMarker();
-
- //! Create and assign parameters.
- Standard_EXPORT OpenGl_AspectMarker (const Handle(Graphic3d_AspectMarker3d)& theAspect);
-
- //! Return the aspect.
- const Handle(Graphic3d_AspectMarker3d)& Aspect() const { return myAspect; }
-
- //! Assign new aspect.
- Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect);
-
- //! @return marker size
- Standard_ShortReal MarkerSize() const { return myMarkerSize; }
-
- //! Init and return OpenGl point sprite resource.
- //! @return point sprite texture.
- const Handle(OpenGl_TextureSet)& SpriteRes (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsSpriteReady())
- {
- myResources.BuildSprites (theCtx,
- myAspect->GetMarkerImage(),
- myAspect->Type(),
- myAspect->Scale(),
- myAspect->ColorRGBA(),
- myMarkerSize);
- myResources.SetSpriteReady();
- }
-
- return myResources.Sprite();
- }
-
- //! Init and return OpenGl highlight point sprite resource.
- //! @return point sprite texture for highlight.
- const Handle(OpenGl_TextureSet)& SpriteHighlightRes (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsSpriteReady())
- {
- myResources.BuildSprites (theCtx,
- myAspect->GetMarkerImage(),
- myAspect->Type(),
- myAspect->Scale(),
- myAspect->ColorRGBA(),
- myMarkerSize);
- myResources.SetSpriteReady();
- }
-
- return myResources.SpriteA();
- }
-
- //! Init and return OpenGl shader program resource.
- //! @return shader program resource.
- const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsShaderReady())
- {
- myResources.BuildShader (theCtx, myAspect->ShaderProgram());
- myResources.SetShaderReady();
- }
-
- return myResources.ShaderProgram();
- }
-
- Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
- Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
-
- //! Update presentation aspects parameters after their modification.
- virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
-
-protected:
-
- //! OpenGl resources
- mutable struct Resources
- {
- public:
-
- //! Empty constructor.
- Resources()
- : myIsSpriteReady (Standard_False),
- myIsShaderReady (Standard_False) {}
-
- const Handle(OpenGl_TextureSet)& Sprite() const { return mySprite; }
- const Handle(OpenGl_TextureSet)& SpriteA() const { return mySpriteA; }
- const Handle(OpenGl_ShaderProgram)& ShaderProgram() const { return myShaderProgram; }
-
- Standard_Boolean IsSpriteReady() const { return myIsSpriteReady; }
- Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
- void SetSpriteReady() { myIsSpriteReady = Standard_True; }
- void SetShaderReady() { myIsShaderReady = Standard_True; }
-
- //! Update texture resource up-to-date state.
- Standard_EXPORT void UpdateTexturesRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect,
- Standard_ShortReal& theMarkerSize);
-
- //! Update shader resource up-to-date state.
- Standard_EXPORT void UpdateShaderRediness (const Handle(Graphic3d_AspectMarker3d)& theAspect);
-
- //! Release texture resource.
- Standard_EXPORT void ReleaseTextures (OpenGl_Context* theCtx);
-
- //! Release shader resource.
- Standard_EXPORT void ReleaseShaders (OpenGl_Context* theCtx);
-
- //! Build texture resources.
- Standard_EXPORT void BuildSprites (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_MarkerImage)& theMarkerImage,
- const Aspect_TypeOfMarker theType,
- const Standard_ShortReal theScale,
- const Graphic3d_Vec4& theColor,
- Standard_ShortReal& theMarkerSize);
-
- //! Build shader resources.
- Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader);
-
- private:
-
- //! Generate resource keys for a sprite.
- static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
- const Aspect_TypeOfMarker theType,
- const Standard_ShortReal theScale,
- const Graphic3d_Vec4& theColor,
- TCollection_AsciiString& theKey,
- TCollection_AsciiString& theKeyA);
-
- private:
-
- Handle(OpenGl_TextureSet) mySprite;
- Handle(OpenGl_TextureSet) mySpriteA;
- Handle(OpenGl_ShaderProgram) myShaderProgram;
- TCollection_AsciiString myShaderProgramId;
- Standard_Boolean myIsSpriteReady;
- Standard_Boolean myIsShaderReady;
-
- } myResources;
-
- Handle(Graphic3d_AspectMarker3d) myAspect;
- mutable Standard_ShortReal myMarkerSize;
-
-public:
-
- DEFINE_STANDARD_ALLOC
-
-};
-
-#endif // OpenGl_AspectMarker_Header
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2013 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.
-
-#include <Graphic3d_ShaderProgram.hxx>
-
-#include <OpenGl_AspectText.hxx>
-#include <OpenGl_Context.hxx>
-#include <OpenGl_Workspace.hxx>
-#include <OpenGl_ShaderManager.hxx>
-#include <OpenGl_ShaderProgram.hxx>
-
-namespace
-{
- static const TCollection_AsciiString THE_EMPTY_KEY;
-}
-
-// =======================================================================
-// function : OpenGl_AspectText
-// purpose :
-// =======================================================================
-OpenGl_AspectText::OpenGl_AspectText()
-: myAspect (new Graphic3d_AspectText3d (Quantity_Color (Quantity_NOC_WHITE), "Courier", 1.0, 0.0))
-{
- //
-}
-
-// =======================================================================
-// function : OpenGl_AspectText
-// purpose :
-// =======================================================================
-OpenGl_AspectText::OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect)
-{
- SetAspect (theAspect);
-}
-
-// =======================================================================
-// function : ~OpenGl_AspectText
-// purpose :
-// =======================================================================
-OpenGl_AspectText::~OpenGl_AspectText()
-{
- //
-}
-
-// =======================================================================
-// function : SetAspect
-// purpose :
-// =======================================================================
-void OpenGl_AspectText::SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect)
-{
- myAspect = theAspect;
- const TCollection_AsciiString& aShaderKey = myAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : myAspect->ShaderProgram()->GetId();
- if (aShaderKey.IsEmpty() || myResources.ShaderProgramId != aShaderKey)
- {
- myResources.ResetShaderReadiness();
- }
-}
-
-// =======================================================================
-// function : Render
-// purpose :
-// =======================================================================
-void OpenGl_AspectText::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
-{
- theWorkspace->SetAspectText (this);
-}
-
-// =======================================================================
-// function : Release
-// purpose :
-// =======================================================================
-void OpenGl_AspectText::Release (OpenGl_Context* theContext)
-{
- if (!myResources.ShaderProgram.IsNull()
- && theContext)
- {
- theContext->ShaderManager()->Unregister (myResources.ShaderProgramId,
- myResources.ShaderProgram);
- }
- myResources.ShaderProgramId.Clear();
- myResources.ResetShaderReadiness();
-}
-
-// =======================================================================
-// function : BuildShader
-// purpose :
-// =======================================================================
-void OpenGl_AspectText::Resources::BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader)
-{
- if (theCtx->core20fwd == NULL)
- {
- return;
- }
-
- // release old shader program resources
- if (!ShaderProgram.IsNull())
- {
- theCtx->ShaderManager()->Unregister (ShaderProgramId, ShaderProgram);
- ShaderProgramId.Clear();
- ShaderProgram.Nullify();
- }
- if (theShader.IsNull())
- {
- return;
- }
-
- theCtx->ShaderManager()->Create (theShader, ShaderProgramId, ShaderProgram);
-}
+++ /dev/null
-// Created on: 2011-07-13
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2013 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 OpenGl_AspectText_Header
-#define OpenGl_AspectText_Header
-
-#include <Font_FontAspect.hxx>
-#include <Graphic3d_AspectText3d.hxx>
-
-#include <TCollection_AsciiString.hxx>
-
-#include <OpenGl_Element.hxx>
-
-class OpenGl_ShaderProgram;
-
-//! Text representation parameters
-class OpenGl_AspectText : public OpenGl_Element
-{
-
-public:
-
- //! Empty constructor.
- Standard_EXPORT OpenGl_AspectText();
-
- //! Create and assign parameters.
- Standard_EXPORT OpenGl_AspectText (const Handle(Graphic3d_AspectText3d)& theAspect);
-
- //! Destructor.
- Standard_EXPORT virtual ~OpenGl_AspectText();
-
- //! Return text aspect.
- const Handle(Graphic3d_AspectText3d)& Aspect() const { return myAspect; }
-
- //! Assign new parameters.
- Standard_EXPORT void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect);
-
- //! Init and return OpenGl shader program resource.
- //! @return shader program resource.
- const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
- {
- if (!myResources.IsShaderReady())
- {
- myResources.BuildShader (theCtx, myAspect->ShaderProgram());
- myResources.SetShaderReady();
- }
-
- return myResources.ShaderProgram;
- }
-
- Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
- Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
-
- //! Update presentation aspects parameters after their modification.
- virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
-
-protected:
-
- //! OpenGl resources
- mutable struct Resources
- {
- public:
- Resources() : myIsShaderReady (Standard_False) {}
-
- Standard_Boolean IsShaderReady() const { return myIsShaderReady; }
- void SetShaderReady() { myIsShaderReady = Standard_True; }
- void ResetShaderReadiness() { myIsShaderReady = Standard_False; }
-
- Standard_EXPORT void BuildShader (const Handle(OpenGl_Context)& theCtx,
- const Handle(Graphic3d_ShaderProgram)& theShader);
-
- Handle(OpenGl_ShaderProgram) ShaderProgram;
- TCollection_AsciiString ShaderProgramId;
-
- private:
-
- Standard_Boolean myIsShaderReady;
-
- } myResources;
-
- Handle(Graphic3d_AspectText3d) myAspect;
-
-public:
-
- DEFINE_STANDARD_ALLOC
-
-};
-
-#endif // OpenGl_AspectText_Header
--- /dev/null
+// Copyright (c) 2019 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.
+
+#include <OpenGl_Aspects.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_Workspace.hxx>
+
+#include <Graphic3d_TypeOfReflection.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
+
+namespace
+{
+ //! Initialize default material in this way for backward compatibility.
+ inline Graphic3d_MaterialAspect initDefaultMaterial()
+ {
+ Graphic3d_MaterialAspect aMat;
+ aMat.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+ aMat.SetAmbient (0.2f);
+ aMat.SetDiffuse (0.8f);
+ aMat.SetSpecular (0.1f);
+ aMat.SetEmissive (0.0f);
+ aMat.SetAmbientColor (Quantity_NOC_WHITE);
+ aMat.SetDiffuseColor (Quantity_NOC_WHITE);
+ aMat.SetEmissiveColor(Quantity_NOC_WHITE);
+ aMat.SetSpecularColor(Quantity_NOC_WHITE);
+ aMat.SetShininess (10.0f / 128.0f);
+ aMat.SetRefractionIndex (1.0f);
+ return aMat;
+ }
+
+ static const Graphic3d_MaterialAspect THE_DEFAULT_MATERIAL = initDefaultMaterial();
+}
+
+// =======================================================================
+// function : OpenGl_Aspects
+// purpose :
+// =======================================================================
+OpenGl_Aspects::OpenGl_Aspects()
+: myAspect (new Graphic3d_Aspects()),
+ myShadingModel (Graphic3d_TOSM_UNLIT)
+{
+ myAspect->SetInteriorStyle (Aspect_IS_SOLID);
+ myAspect->SetInteriorColor (Quantity_NOC_WHITE);
+ myAspect->SetEdgeColor (Quantity_NOC_WHITE);
+ myAspect->SetFrontMaterial (THE_DEFAULT_MATERIAL);
+ myAspect->SetBackMaterial (THE_DEFAULT_MATERIAL);
+ myAspect->SetShadingModel (myShadingModel);
+ myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
+}
+
+// =======================================================================
+// function : OpenGl_Aspects
+// purpose :
+// =======================================================================
+OpenGl_Aspects::OpenGl_Aspects (const Handle(Graphic3d_Aspects)& theAspect)
+: myShadingModel (Graphic3d_TOSM_DEFAULT)
+{
+ SetAspect (theAspect);
+}
+
+// =======================================================================
+// function : SetAspect
+// purpose :
+// =======================================================================
+void OpenGl_Aspects::SetAspect (const Handle(Graphic3d_Aspects)& theAspect)
+{
+ myAspect = theAspect;
+
+ const Graphic3d_MaterialAspect& aMat = theAspect->FrontMaterial();
+ myShadingModel = theAspect->ShadingModel() != Graphic3d_TOSM_UNLIT
+ && (aMat.ReflectionMode (Graphic3d_TOR_AMBIENT)
+ || aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)
+ || aMat.ReflectionMode (Graphic3d_TOR_SPECULAR)
+ || aMat.ReflectionMode (Graphic3d_TOR_EMISSION))
+ ? theAspect->ShadingModel()
+ : Graphic3d_TOSM_UNLIT;
+
+ // invalidate resources
+ myResTextureSet.UpdateRediness (myAspect->TextureSet());
+ myResSprite.UpdateRediness (myAspect);
+ myResProgram.UpdateRediness (myAspect);
+}
+
+// =======================================================================
+// function : Render
+// purpose :
+// =======================================================================
+void OpenGl_Aspects::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
+{
+ theWorkspace->SetAspects (this);
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void OpenGl_Aspects::Release (OpenGl_Context* theContext)
+{
+ myResTextureSet.Release (theContext);
+ myResSprite.Release (theContext);
+ myResProgram.Release (theContext);
+}
--- /dev/null
+// Copyright (c) 2019 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 _OpenGl_Aspects_Header
+#define _OpenGl_Aspects_Header
+
+#include <OpenGl_Element.hxx>
+#include <OpenGl_AspectsProgram.hxx>
+#include <OpenGl_AspectsTextureSet.hxx>
+#include <OpenGl_AspectsSprite.hxx>
+#include <Graphic3d_Aspects.hxx>
+#include <Graphic3d_BSDF.hxx>
+
+//! The element holding Graphic3d_Aspects.
+class OpenGl_Aspects : public OpenGl_Element
+{
+public:
+
+ //! Empty constructor.
+ Standard_EXPORT OpenGl_Aspects();
+
+ //! Create and assign parameters.
+ Standard_EXPORT OpenGl_Aspects (const Handle(Graphic3d_Aspects)& theAspect);
+
+ //! Return aspect.
+ const Handle(Graphic3d_Aspects)& Aspect() const { return myAspect; }
+
+ //! Assign parameters.
+ Standard_EXPORT void SetAspect (const Handle(Graphic3d_Aspects)& theAspect);
+
+ //! Returns Shading Model.
+ Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
+
+ //! Set if lighting should be disabled or not.
+ void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
+
+ //! Returns textures map.
+ const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx) const
+ {
+ return myResTextureSet.TextureSet (theCtx, myAspect->TextureSet());
+ }
+
+ //! Init and return OpenGl shader program resource.
+ //! @return shader program resource.
+ const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
+ {
+ return myResProgram.ShaderProgram (theCtx, myAspect->ShaderProgram());
+ }
+
+ //! @return marker size
+ Standard_ShortReal MarkerSize() const { return myResSprite.MarkerSize(); }
+
+ //! Init and return OpenGl point sprite resource.
+ //! @return point sprite texture.
+ const Handle(OpenGl_TextureSet)& SpriteRes (const Handle(OpenGl_Context)& theCtx) const
+ {
+ return myResSprite.Sprite (theCtx, myAspect);
+ }
+
+ //! Init and return OpenGl highlight point sprite resource.
+ //! @return point sprite texture for highlight.
+ const Handle(OpenGl_TextureSet)& SpriteHighlightRes (const Handle(OpenGl_Context)& theCtx) const
+ {
+ return myResSprite.SpriteA (theCtx, myAspect);
+ }
+
+ Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
+ Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
+
+ //! Update presentation aspects parameters after their modification.
+ virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
+
+protected:
+
+ //! OpenGl resources
+ mutable OpenGl_AspectsProgram myResProgram;
+ mutable OpenGl_AspectsTextureSet myResTextureSet;
+ mutable OpenGl_AspectsSprite myResSprite;
+
+ Handle(Graphic3d_Aspects) myAspect;
+ Graphic3d_TypeOfShadingModel myShadingModel;
+
+public:
+
+ DEFINE_STANDARD_ALLOC
+
+};
+
+#endif // _OpenGl_Aspects_Header
--- /dev/null
+// Copyright (c) 2019 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.
+
+#include <OpenGl_AspectsProgram.hxx>
+
+#include <OpenGl_Context.hxx>
+#include <OpenGl_ShaderManager.hxx>
+#include <OpenGl_ShaderProgram.hxx>
+
+namespace
+{
+ static const TCollection_AsciiString THE_EMPTY_KEY;
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void OpenGl_AspectsProgram::Release (OpenGl_Context* theCtx)
+{
+ if (!myShaderProgram.IsNull() && theCtx != NULL)
+ {
+ theCtx->ShaderManager()->Unregister (myShaderProgramId,
+ myShaderProgram);
+ }
+ myShaderProgramId.Clear();
+ myIsShaderReady = Standard_False;
+}
+
+// =======================================================================
+// function : UpdateRediness
+// purpose :
+// =======================================================================
+void OpenGl_AspectsProgram::UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect)
+{
+ const TCollection_AsciiString& aShaderKey = theAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : theAspect->ShaderProgram()->GetId();
+ if (aShaderKey.IsEmpty() || myShaderProgramId != aShaderKey)
+ {
+ myIsShaderReady = Standard_False;
+ }
+}
+
+// =======================================================================
+// function : build
+// purpose :
+// =======================================================================
+void OpenGl_AspectsProgram::build (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_ShaderProgram)& theShader)
+{
+ if (theCtx->core20fwd == NULL)
+ {
+ return;
+ }
+
+ // release old shader program resources
+ if (!myShaderProgram.IsNull())
+ {
+ theCtx->ShaderManager()->Unregister (myShaderProgramId, myShaderProgram);
+ myShaderProgramId.Clear();
+ myShaderProgram.Nullify();
+ }
+ if (theShader.IsNull())
+ {
+ return;
+ }
+
+ theCtx->ShaderManager()->Create (theShader, myShaderProgramId, myShaderProgram);
+}
--- /dev/null
+// Copyright (c) 2019 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 _OpenGl_AspectsProgram_Header
+#define _OpenGl_AspectsProgram_Header
+
+#include <Graphic3d_ShaderProgram.hxx>
+
+class Graphic3d_Aspects;
+class OpenGl_Context;
+class OpenGl_ShaderProgram;
+
+//! OpenGl resources for custom shading program.
+class OpenGl_AspectsProgram
+{
+public:
+ DEFINE_STANDARD_ALLOC
+public:
+ //! Empty constructor.
+ OpenGl_AspectsProgram() : myIsShaderReady (false) {}
+
+ //! Return shading program.
+ const Handle(OpenGl_ShaderProgram)& ShaderProgram (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_ShaderProgram)& theShader)
+ {
+ if (!myIsShaderReady)
+ {
+ build (theCtx, theShader);
+ myIsShaderReady = true;
+ }
+ return myShaderProgram;
+ }
+
+ //! Update shader resource up-to-date state.
+ Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
+
+ //! Release resource.
+ Standard_EXPORT void Release (OpenGl_Context* theCtx);
+
+private:
+
+ //! Build shader resource.
+ Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_ShaderProgram)& theShader);
+
+private:
+
+ Handle(OpenGl_ShaderProgram) myShaderProgram;
+ TCollection_AsciiString myShaderProgramId;
+ Standard_Boolean myIsShaderReady;
+};
+
+#endif // _OpenGl_Aspects_Header
--- /dev/null
+// Copyright (c) 2019 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.
+
+#include <OpenGl_AspectsSprite.hxx>
+
+#include <OpenGl_Context.hxx>
+#include <OpenGl_PointSprite.hxx>
+#include <OpenGl_TextureSet.hxx>
+
+#include <Image_PixMap.hxx>
+#include <Graphic3d_MarkerImage.hxx>
+#include <TColStd_HArray1OfByte.hxx>
+
+namespace
+{
+ static const TCollection_AsciiString THE_EMPTY_KEY;
+
+ //! Draw inner point as filled rectangle
+ static Handle(TColStd_HArray1OfByte) fillPointBitmap (const Standard_Integer theSize)
+ {
+ // draw inner point as filled rectangle
+ const Standard_Integer aNumOfBytes = (theSize / 8 + (theSize % 8 ? 1 : 0)) * theSize;
+ Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
+ for (Standard_Integer anIter = 0; anIter < aBitMap->Length(); ++anIter)
+ {
+ aBitMap->SetValue (anIter, 255);
+ }
+ return aBitMap;
+ }
+}
+
+// Following Section relates to default markers
+
+#define TEL_NO_OF_SIZES 13
+#define TEL_PM_START_SIZE 1.0
+#define TEL_PM_END_SIZE 7.0
+
+struct PM_FONT_INFO
+{
+ float width, height;
+ int offset;
+};
+typedef PM_FONT_INFO* pm_font_info;
+
+#define PM_PLUS_10_NUM 9*2
+#define PM_PLUS_15_NUM 11*2
+#define PM_PLUS_20_NUM 13*2
+#define PM_PLUS_25_NUM 15*2
+#define PM_PLUS_30_NUM 17*3
+#define PM_PLUS_35_NUM 19*3
+#define PM_PLUS_40_NUM 21*3
+#define PM_PLUS_45_NUM 23*3
+#define PM_PLUS_50_NUM 25*4
+#define PM_PLUS_55_NUM 27*4
+#define PM_PLUS_60_NUM 29*4
+#define PM_PLUS_65_NUM 31*4
+#define PM_PLUS_70_NUM 32*4
+
+#define PM_STAR_10_NUM 9
+#define PM_STAR_15_NUM 11*2
+#define PM_STAR_20_NUM 13*2
+#define PM_STAR_25_NUM 15*2
+#define PM_STAR_30_NUM 17*2
+#define PM_STAR_35_NUM 19*2
+#define PM_STAR_40_NUM 21*3
+#define PM_STAR_45_NUM 23*3
+#define PM_STAR_50_NUM 25*3
+#define PM_STAR_55_NUM 27*3
+#define PM_STAR_60_NUM 29*4
+#define PM_STAR_65_NUM 32*4
+#define PM_STAR_70_NUM 32*4
+
+#define PM_CIRC_10_NUM 7
+#define PM_CIRC_15_NUM 9*2
+#define PM_CIRC_20_NUM 9*2
+#define PM_CIRC_25_NUM 11*2
+#define PM_CIRC_30_NUM 13*2
+#define PM_CIRC_35_NUM 15*2
+#define PM_CIRC_40_NUM 17*3
+#define PM_CIRC_45_NUM 19*3
+#define PM_CIRC_50_NUM 21*3
+#define PM_CIRC_55_NUM 23*3
+#define PM_CIRC_60_NUM 25*4
+#define PM_CIRC_65_NUM 27*4
+#define PM_CIRC_70_NUM 29*4
+
+#define PM_CROSS_10_NUM 7
+#define PM_CROSS_15_NUM 9*2
+#define PM_CROSS_20_NUM 11*2
+#define PM_CROSS_25_NUM 13*2
+#define PM_CROSS_30_NUM 15*2
+#define PM_CROSS_35_NUM 17*3
+#define PM_CROSS_40_NUM 19*3
+#define PM_CROSS_45_NUM 21*3
+#define PM_CROSS_50_NUM 23*3
+#define PM_CROSS_55_NUM 25*4
+#define PM_CROSS_60_NUM 27*4
+#define PM_CROSS_65_NUM 32*4
+#define PM_CROSS_70_NUM 32*4
+
+#define PM_PLUS_10_OFT 0
+#define PM_PLUS_15_OFT PM_PLUS_10_OFT + PM_PLUS_10_NUM
+#define PM_PLUS_20_OFT PM_PLUS_15_OFT + PM_PLUS_15_NUM
+#define PM_PLUS_25_OFT PM_PLUS_20_OFT + PM_PLUS_20_NUM
+#define PM_PLUS_30_OFT PM_PLUS_25_OFT + PM_PLUS_25_NUM
+#define PM_PLUS_35_OFT PM_PLUS_30_OFT + PM_PLUS_30_NUM
+#define PM_PLUS_40_OFT PM_PLUS_35_OFT + PM_PLUS_35_NUM
+#define PM_PLUS_45_OFT PM_PLUS_40_OFT + PM_PLUS_40_NUM
+#define PM_PLUS_50_OFT PM_PLUS_45_OFT + PM_PLUS_45_NUM
+#define PM_PLUS_55_OFT PM_PLUS_50_OFT + PM_PLUS_50_NUM
+#define PM_PLUS_60_OFT PM_PLUS_55_OFT + PM_PLUS_55_NUM
+#define PM_PLUS_65_OFT PM_PLUS_60_OFT + PM_PLUS_60_NUM
+#define PM_PLUS_70_OFT PM_PLUS_65_OFT + PM_PLUS_65_NUM
+
+#define PM_STAR_10_OFT PM_PLUS_70_OFT + PM_PLUS_70_NUM
+#define PM_STAR_15_OFT PM_STAR_10_OFT + PM_STAR_10_NUM
+#define PM_STAR_20_OFT PM_STAR_15_OFT + PM_STAR_15_NUM
+#define PM_STAR_25_OFT PM_STAR_20_OFT + PM_STAR_20_NUM
+#define PM_STAR_30_OFT PM_STAR_25_OFT + PM_STAR_25_NUM
+#define PM_STAR_35_OFT PM_STAR_30_OFT + PM_STAR_30_NUM
+#define PM_STAR_40_OFT PM_STAR_35_OFT + PM_STAR_35_NUM
+#define PM_STAR_45_OFT PM_STAR_40_OFT + PM_STAR_40_NUM
+#define PM_STAR_50_OFT PM_STAR_45_OFT + PM_STAR_45_NUM
+#define PM_STAR_55_OFT PM_STAR_50_OFT + PM_STAR_50_NUM
+#define PM_STAR_60_OFT PM_STAR_55_OFT + PM_STAR_55_NUM
+#define PM_STAR_65_OFT PM_STAR_60_OFT + PM_STAR_60_NUM
+#define PM_STAR_70_OFT PM_STAR_65_OFT + PM_STAR_65_NUM
+
+#define PM_CIRC_10_OFT PM_STAR_70_OFT + PM_STAR_70_NUM
+#define PM_CIRC_15_OFT PM_CIRC_10_OFT + PM_CIRC_10_NUM
+#define PM_CIRC_20_OFT PM_CIRC_15_OFT + PM_CIRC_15_NUM
+#define PM_CIRC_25_OFT PM_CIRC_20_OFT + PM_CIRC_20_NUM
+#define PM_CIRC_30_OFT PM_CIRC_25_OFT + PM_CIRC_25_NUM
+#define PM_CIRC_35_OFT PM_CIRC_30_OFT + PM_CIRC_30_NUM
+#define PM_CIRC_40_OFT PM_CIRC_35_OFT + PM_CIRC_35_NUM
+#define PM_CIRC_45_OFT PM_CIRC_40_OFT + PM_CIRC_40_NUM
+#define PM_CIRC_50_OFT PM_CIRC_45_OFT + PM_CIRC_45_NUM
+#define PM_CIRC_55_OFT PM_CIRC_50_OFT + PM_CIRC_50_NUM
+#define PM_CIRC_60_OFT PM_CIRC_55_OFT + PM_CIRC_55_NUM
+#define PM_CIRC_65_OFT PM_CIRC_60_OFT + PM_CIRC_60_NUM
+#define PM_CIRC_70_OFT PM_CIRC_65_OFT + PM_CIRC_65_NUM
+
+#define PM_CROSS_10_OFT PM_CIRC_70_OFT + PM_CIRC_70_NUM
+#define PM_CROSS_15_OFT PM_CROSS_10_OFT + PM_CROSS_10_NUM
+#define PM_CROSS_20_OFT PM_CROSS_15_OFT + PM_CROSS_15_NUM
+#define PM_CROSS_25_OFT PM_CROSS_20_OFT + PM_CROSS_20_NUM
+#define PM_CROSS_30_OFT PM_CROSS_25_OFT + PM_CROSS_25_NUM
+#define PM_CROSS_35_OFT PM_CROSS_30_OFT + PM_CROSS_30_NUM
+#define PM_CROSS_40_OFT PM_CROSS_35_OFT + PM_CROSS_35_NUM
+#define PM_CROSS_45_OFT PM_CROSS_40_OFT + PM_CROSS_40_NUM
+#define PM_CROSS_50_OFT PM_CROSS_45_OFT + PM_CROSS_45_NUM
+#define PM_CROSS_55_OFT PM_CROSS_50_OFT + PM_CROSS_50_NUM
+#define PM_CROSS_60_OFT PM_CROSS_55_OFT + PM_CROSS_55_NUM
+#define PM_CROSS_65_OFT PM_CROSS_60_OFT + PM_CROSS_60_NUM
+#define PM_CROSS_70_OFT PM_CROSS_65_OFT + PM_CROSS_65_NUM
+
+static const PM_FONT_INFO arrPMFontInfo[][TEL_NO_OF_SIZES] =
+{
+ // TOM_POINT - not used
+ {{0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0},
+ {0, 0, 0}},
+
+ // TOM_PLUS
+ {{ 9.f, 9.f, PM_PLUS_10_OFT},
+ {11.f, 11.f, PM_PLUS_15_OFT},
+ {13.f, 13.f, PM_PLUS_20_OFT},
+ {15.f, 15.f, PM_PLUS_25_OFT},
+ {17.f, 17.f, PM_PLUS_30_OFT},
+ {19.f, 19.f, PM_PLUS_35_OFT},
+ {21.f, 21.f, PM_PLUS_40_OFT},
+ {23.f, 23.f, PM_PLUS_45_OFT},
+ {25.f, 25.f, PM_PLUS_50_OFT},
+ {27.f, 27.f, PM_PLUS_55_OFT},
+ {29.f, 29.f, PM_PLUS_60_OFT},
+ {31.f, 31.f, PM_PLUS_65_OFT},
+ {32.f, 32.f, PM_PLUS_70_OFT}},
+
+ // TOM_STAR
+ {{ 7.f, 9.f, PM_STAR_10_OFT},
+ {9.f, 11.f, PM_STAR_15_OFT},
+ {11.f, 13.f, PM_STAR_20_OFT},
+ {13.f, 15.f, PM_STAR_25_OFT},
+ {13.f, 17.f, PM_STAR_30_OFT},
+ {15.f, 19.f, PM_STAR_35_OFT},
+ {17.f, 21.f, PM_STAR_40_OFT},
+ {19.f, 23.f, PM_STAR_45_OFT},
+ {21.f, 25.f, PM_STAR_50_OFT},
+ {23.f, 27.f, PM_STAR_55_OFT},
+ {25.f, 29.f, PM_STAR_60_OFT},
+ {32.f, 32.f, PM_STAR_65_OFT},
+ {32.f, 32.f, PM_STAR_70_OFT}},
+
+ // TOM_X
+ {{ 7.f, 7.f, PM_CROSS_10_OFT},
+ { 9.f, 9.f, PM_CROSS_15_OFT},
+ {11.f, 11.f, PM_CROSS_20_OFT},
+ {13.f, 13.f, PM_CROSS_25_OFT},
+ {15.f, 15.f, PM_CROSS_30_OFT},
+ {17.f, 17.f, PM_CROSS_35_OFT},
+ {19.f, 19.f, PM_CROSS_40_OFT},
+ {21.f, 21.f, PM_CROSS_45_OFT},
+ {23.f, 23.f, PM_CROSS_50_OFT},
+ {25.f, 25.f, PM_CROSS_55_OFT},
+ {27.f, 27.f, PM_CROSS_60_OFT},
+ {32.f, 32.f, PM_CROSS_65_OFT},
+ {32.f, 32.f, PM_CROSS_70_OFT}},
+
+ // TOM_O
+ {{ 7.f, 7.f, PM_CIRC_10_OFT},
+ { 9.f, 9.f, PM_CIRC_15_OFT},
+ { 9.f, 9.f, PM_CIRC_20_OFT},
+ {11.f, 11.f, PM_CIRC_25_OFT},
+ {13.f, 13.f, PM_CIRC_30_OFT},
+ {15.f, 15.f, PM_CIRC_35_OFT},
+ {17.f, 17.f, PM_CIRC_40_OFT},
+ {19.f, 19.f, PM_CIRC_45_OFT},
+ {21.f, 21.f, PM_CIRC_50_OFT},
+ {23.f, 23.f, PM_CIRC_55_OFT},
+ {25.f, 25.f, PM_CIRC_60_OFT},
+ {27.f, 27.f, PM_CIRC_65_OFT},
+ {29.f, 29.f, PM_CIRC_70_OFT}}
+};
+
+static const Standard_Byte OpenGl_AspectMarker_myMarkerRaster[] =
+{
+ // TYPE = PLUS
+
+ 0x08,0x00,
+ 0x08,0x00,
+ 0x08,0x00,
+ 0x08,0x00,
+ 0xff,0x80,
+ 0x08,0x00,
+ 0x08,0x00,
+ 0x08,0x00,
+ 0x08,0x00, // PLUS 9x9 = 1.0
+
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0xff,0xe0,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00, // PLUS 11x11 = 1.5
+
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0xff,0xf8,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00, // PLUS 13x13 = 2.0
+
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0xff,0xfe,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00, // PLUS 15x15 = 2.5
+
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0xff,0xff, 0x80,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00, // PLUS 17x17 = 3.0
+
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0xff,0xff, 0xe0,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00, // PLUS 19x19 = 3.5
+
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0xff,0xff, 0xf8,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00, // PLUS 21x21 = 4.0
+
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0xff,0xff, 0xfe,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00, // PLUS 23x23 = 4.5
+
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0xff,0xff, 0xff,0x80,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00, // PLUS 25x25 = 5.0
+
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0xff,0xff, 0xff,0xe0,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00, // PLUS 27x27 = 5.5
+
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0xff,0xff, 0xff,0xf8,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00,
+ 0x00,0x02, 0x00,0x00, // PLUS 29x29 = 6.0
+
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0xff,0xff, 0xff,0xfd,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00,
+ 0x00,0x01, 0x00,0x00, // PLUS 31x31 = 6.5
+
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0xff,0xff, 0xff,0xff,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00, // PLUS 32x32 = 7.0
+
+ // TYPE = STAR
+
+ 0x10,
+ 0x10,
+ 0xd6,
+ 0x38,
+ 0x10,
+ 0x38,
+ 0xd6,
+ 0x10,
+ 0x10, // STAR 7x9 = 1.0
+
+ 0x08,0x00,
+ 0x08,0x00,
+ 0x08,0x00,
+ 0xc9,0x80,
+ 0x3e,0x00,
+ 0x08,0x00,
+ 0x3e,0x00,
+ 0xc9,0x80,
+ 0x08,0x00,
+ 0x08,0x00,
+ 0x08,0x00, // STAR 9x11 = 1.5
+
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x84,0x20,
+ 0x64,0xc0,
+ 0x1f,0x00,
+ 0x04,0x00,
+ 0x1f,0x00,
+ 0x64,0xc0,
+ 0x84,0x20,
+ 0x04,0x00,
+ 0x04,0x00,
+ 0x04,0x00, // STAR 11x13 = 2.0
+
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x82,0x18,
+ 0x62,0x60,
+ 0x1b,0x80,
+ 0x06,0x00,
+ 0x1b,0x80,
+ 0x62,0x60,
+ 0x82,0x18,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00, // STAR 13x15 = 2.5
+
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x82,0x08,
+ 0x62,0x30,
+ 0x12,0x40,
+ 0x0f,0x80,
+ 0x02,0x00,
+ 0x0f,0x80,
+ 0x12,0x40,
+ 0x62,0x30,
+ 0x82,0x08,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00,
+ 0x02,0x00, // STAR 13x17 = 3.0
+
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0xc1,0x06,
+ 0x21,0x18,
+ 0x19,0x20,
+ 0x07,0xc0,
+ 0x01,0x00,
+ 0x07,0xc0,
+ 0x19,0x20,
+ 0x21,0x18,
+ 0xc1,0x06,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00,
+ 0x01,0x00, // STAR 15x19 = 3.5
+
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x80,0x80, 0x80,
+ 0x60,0x83, 0x00,
+ 0x10,0x8c, 0x00,
+ 0x0c,0x90, 0x00,
+ 0x03,0xe0, 0x00,
+ 0x00,0x80, 0x00,
+ 0x03,0xe0, 0x00,
+ 0x0c,0x90, 0x00,
+ 0x10,0x8c, 0x00,
+ 0x60,0x83, 0x00,
+ 0x80,0x80, 0x80,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00,
+ 0x00,0x80, 0x00, // STAR 17x21 = 4.0
+
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0xc0,0x40, 0x60,
+ 0x30,0x41, 0x80,
+ 0x08,0x42, 0x00,
+ 0x06,0x4c, 0x00,
+ 0x01,0xf0, 0x00,
+ 0x00,0x40, 0x00,
+ 0x01,0xf0, 0x00,
+ 0x06,0x4c, 0x00,
+ 0x08,0x42, 0x00,
+ 0x30,0x41, 0x80,
+ 0xc0,0x40, 0x60,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0x40, 0x00, // STAR 19x23 = 4.5
+
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x80,0x20, 0x08,
+ 0x60,0x20, 0x30,
+ 0x18,0x20, 0xc0,
+ 0x04,0x21, 0x00,
+ 0x03,0x26, 0x00,
+ 0x00,0xf8, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0xf8, 0x00,
+ 0x03,0x26, 0x00,
+ 0x04,0x21, 0x00,
+ 0x18,0x20, 0xc0,
+ 0x60,0x20, 0x30,
+ 0x80,0x20, 0x08,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x20, 0x00, // STAR 21x25 = 5.0
+
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0xc0,0x10, 0x06,
+ 0x30,0x10, 0x18,
+ 0x08,0x10, 0x60,
+ 0x06,0x10, 0x80,
+ 0x01,0x93, 0x00,
+ 0x00,0x7c, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x7c, 0x00,
+ 0x01,0x93, 0x00,
+ 0x06,0x10, 0x80,
+ 0x08,0x10, 0x60,
+ 0x30,0x10, 0x18,
+ 0xc0,0x10, 0x06,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x10, 0x00, // STAR 23x27 = 5.5
+
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x80,0x08, 0x00,0x80,
+ 0x60,0x08, 0x03,0x00,
+ 0x18,0x08, 0x0c,0x00,
+ 0x04,0x08, 0x30,0x00,
+ 0x03,0x08, 0x40,0x00,
+ 0x00,0xc9, 0x80,0x00,
+ 0x00,0x3e, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x3e, 0x00,0x00,
+ 0x00,0xc9, 0x80,0x00,
+ 0x03,0x08, 0x40,0x00,
+ 0x04,0x08, 0x30,0x00,
+ 0x18,0x08, 0x0c,0x00,
+ 0x60,0x08, 0x03,0x00,
+ 0x80,0x08, 0x00,0x80,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00, // STAR 25x29 = 6.0
+
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x30,0x00, 0x80,0x06,
+ 0x0c,0x00, 0x80,0x18,
+ 0x03,0x00, 0x80,0x60,
+ 0x00,0xc0, 0x81,0x80,
+ 0x00,0x30, 0x86,0x00,
+ 0x00,0x0c, 0x98,0x00,
+ 0x00,0x03, 0xe0,0x00,
+ 0x00,0x03, 0xe0,0x00,
+ 0x00,0x0c, 0x98,0x00,
+ 0x00,0x30, 0x86,0x00,
+ 0x00,0xc0, 0x81,0x80,
+ 0x03,0x00, 0x80,0x60,
+ 0x0c,0x00, 0x80,0x18,
+ 0x30,0x00, 0x80,0x06,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x80,0x00,
+ 0x00,0x00, 0x00,0x00,
+ 0x00,0x00, 0x00,0x00, // STAR 32x32 = 6.5
+
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x10, 0x00, 0x80, 0x04,
+ 0x0c, 0x00, 0x80, 0x18,
+ 0x02, 0x00, 0x80, 0x20,
+ 0x01, 0x80, 0x80, 0xc0,
+ 0x00, 0x40, 0x81, 0x00,
+ 0x00, 0x30, 0x86, 0x00,
+ 0x00, 0x08, 0x88, 0x00,
+ 0x00, 0x06, 0xb0, 0x00,
+ 0x00, 0x01, 0xc0, 0x00,
+ 0x00, 0x06, 0xb0, 0x00,
+ 0x00, 0x08, 0x88, 0x00,
+ 0x00, 0x30, 0x86, 0x00,
+ 0x00, 0x40, 0x81, 0x00,
+ 0x01, 0x80, 0x80, 0xc0,
+ 0x02, 0x00, 0x80, 0x20,
+ 0x0c, 0x00, 0x80, 0x18,
+ 0x10, 0x00, 0x80, 0x04,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00,
+ 0x00, 0x00, 0x80, 0x00, // STAR 32x32 = 7.0
+
+ // TYPE = CIRC
+
+ 0x38,
+ 0x44,
+ 0x82,
+ 0x82,
+ 0x82,
+ 0x44,
+ 0x38, // CIRC 7x7 = 1.0
+
+ 0x3c,0x00,
+ 0x42,0x00,
+ 0x81,0x00,
+ 0x81,0x00,
+ 0x81,0x00,
+ 0x81,0x00,
+ 0x42,0x00,
+ 0x3c,0x00,
+ 0x00,0x00, //CIRC 9x9 = 1.5
+
+ 0x3e,0x00,
+ 0x41,0x00,
+ 0x81,0x80,
+ 0x80,0x80,
+ 0x80,0x80,
+ 0x80,0x80,
+ 0x81,0x80,
+ 0x41,0x00,
+ 0x3e,0x00, // CIRC 9x9 = 2.0
+
+ 0x1f,0x00,
+ 0x20,0x80,
+ 0x40,0x40,
+ 0x80,0x20,
+ 0x80,0x20,
+ 0x80,0x20,
+ 0x80,0x20,
+ 0x80,0x20,
+ 0x40,0x40,
+ 0x20,0x80,
+ 0x1f,0x00, // CIRC 11x11 = 2.5
+
+ 0x0f,0x80,
+ 0x10,0x40,
+ 0x20,0x20,
+ 0x40,0x10,
+ 0x80,0x08,
+ 0x80,0x08,
+ 0x80,0x08,
+ 0x80,0x08,
+ 0x80,0x08,
+ 0x40,0x10,
+ 0x20,0x20,
+ 0x10,0x40,
+ 0x0f,0x80, // CIRC 13x13 = 3.0
+
+ 0x07,0xc0,
+ 0x18,0x30,
+ 0x20,0x08,
+ 0x40,0x04,
+ 0x40,0x04,
+ 0x80,0x02,
+ 0x80,0x02,
+ 0x80,0x02,
+ 0x80,0x02,
+ 0x80,0x02,
+ 0x40,0x04,
+ 0x40,0x04,
+ 0x20,0x08,
+ 0x18,0x30,
+ 0x07,0xc0, // CIRC 15x15 = 3.5
+
+ 0x03,0xe0, 0x00,
+ 0x0c,0x18, 0x00,
+ 0x10,0x04, 0x00,
+ 0x20,0x02, 0x00,
+ 0x40,0x01, 0x00,
+ 0x40,0x01, 0x00,
+ 0x80,0x00, 0x80,
+ 0x80,0x00, 0x80,
+ 0x80,0x00, 0x80,
+ 0x80,0x00, 0x80,
+ 0x80,0x00, 0x80,
+ 0x40,0x01, 0x00,
+ 0x40,0x01, 0x00,
+ 0x20,0x02, 0x00,
+ 0x10,0x04, 0x00,
+ 0x0c,0x18, 0x00,
+ 0x03,0xe0, 0x00, // CIRC 17x17 = 4.0
+
+ 0x03,0xf8, 0x00,
+ 0x0e,0x0e, 0x00,
+ 0x18,0x03, 0x00,
+ 0x20,0x00, 0x80,
+ 0x60,0x00, 0xc0,
+ 0x40,0x00, 0x40,
+ 0xc0,0x00, 0x60,
+ 0x80,0x00, 0x20,
+ 0x80,0x00, 0x20,
+ 0x80,0x00, 0x20,
+ 0x80,0x00, 0x20,
+ 0x80,0x00, 0x20,
+ 0xc0,0x00, 0x60,
+ 0x40,0x00, 0x40,
+ 0x60,0x00, 0xc0,
+ 0x20,0x00, 0x80,
+ 0x18,0x03, 0x00,
+ 0x0e,0x0e, 0x00,
+ 0x03,0xf8, 0x00, // CIRC 19x19 = 4.5
+
+ 0x01,0xfc, 0x00,
+ 0x06,0x03, 0x00,
+ 0x08,0x00, 0x80,
+ 0x10,0x00, 0x40,
+ 0x20,0x00, 0x20,
+ 0x40,0x00, 0x10,
+ 0x40,0x00, 0x10,
+ 0x80,0x00, 0x08,
+ 0x80,0x00, 0x08,
+ 0x80,0x00, 0x08,
+ 0x80,0x00, 0x08,
+ 0x80,0x00, 0x08,
+ 0x80,0x00, 0x08,
+ 0x80,0x00, 0x08,
+ 0x40,0x00, 0x10,
+ 0x40,0x00, 0x10,
+ 0x20,0x00, 0x20,
+ 0x10,0x00, 0x40,
+ 0x08,0x00, 0x80,
+ 0x06,0x03, 0x00,
+ 0x01,0xfc, 0x00, // CIRC 21x21 = 5.0
+
+ 0x00,0xfe, 0x00,
+ 0x03,0x01, 0x80,
+ 0x0c,0x00, 0x60,
+ 0x18,0x00, 0x30,
+ 0x30,0x00, 0x18,
+ 0x20,0x00, 0x08,
+ 0x40,0x00, 0x04,
+ 0x40,0x00, 0x04,
+ 0x80,0x00, 0x02,
+ 0x80,0x00, 0x02,
+ 0x80,0x00, 0x02,
+ 0x80,0x00, 0x02,
+ 0x80,0x00, 0x02,
+ 0x80,0x00, 0x02,
+ 0x80,0x00, 0x02,
+ 0x40,0x00, 0x04,
+ 0x40,0x00, 0x04,
+ 0x20,0x00, 0x08,
+ 0x30,0x00, 0x18,
+ 0x18,0x00, 0x30,
+ 0x0c,0x00, 0x60,
+ 0x03,0x01, 0x80,
+ 0x00,0xfe, 0x00, // CIRC 23x23 = 5.5
+
+ 0x00,0x7f, 0x00,0x00,
+ 0x01,0x80, 0xc0,0x00,
+ 0x06,0x00, 0x30,0x00,
+ 0x08,0x00, 0x08,0x00,
+ 0x10,0x00, 0x04,0x00,
+ 0x20,0x00, 0x02,0x00,
+ 0x20,0x00, 0x02,0x00,
+ 0x40,0x00, 0x01,0x00,
+ 0x40,0x00, 0x01,0x00,
+ 0x80,0x00, 0x00,0x80,
+ 0x80,0x00, 0x00,0x80,
+ 0x80,0x00, 0x00,0x80,
+ 0x80,0x00, 0x00,0x80,
+ 0x80,0x00, 0x00,0x80,
+ 0x80,0x00, 0x00,0x80,
+ 0x80,0x00, 0x00,0x80,
+ 0x40,0x00, 0x01,0x00,
+ 0x40,0x00, 0x01,0x00,
+ 0x20,0x00, 0x02,0x00,
+ 0x20,0x00, 0x02,0x00,
+ 0x10,0x00, 0x04,0x00,
+ 0x08,0x00, 0x08,0x00,
+ 0x06,0x00, 0x30,0x00,
+ 0x01,0x80, 0xc0,0x00,
+ 0x00,0x7f, 0x00,0x00, // CIRC 25x25 = 6.0
+
+ 0x00,0x3f, 0x80,0x00,
+ 0x01,0xc0, 0x70,0x00,
+ 0x03,0x00, 0x18,0x00,
+ 0x0c,0x00, 0x06,0x00,
+ 0x18,0x00, 0x03,0x00,
+ 0x10,0x00, 0x01,0x00,
+ 0x20,0x00, 0x00,0x80,
+ 0x60,0x00, 0x00,0xc0,
+ 0x40,0x00, 0x00,0x40,
+ 0x40,0x00, 0x00,0x40,
+ 0x80,0x00, 0x00,0x20,
+ 0x80,0x00, 0x00,0x20,
+ 0x80,0x00, 0x00,0x20,
+ 0x80,0x00, 0x00,0x20,
+ 0x80,0x00, 0x00,0x20,
+ 0x80,0x00, 0x00,0x20,
+ 0x80,0x00, 0x00,0x20,
+ 0x40,0x00, 0x00,0x40,
+ 0x40,0x00, 0x00,0x40,
+ 0x60,0x00, 0x00,0xc0,
+ 0x20,0x00, 0x00,0x80,
+ 0x10,0x00, 0x01,0x00,
+ 0x18,0x00, 0x03,0x00,
+ 0x0c,0x00, 0x06,0x00,
+ 0x03,0x00, 0x18,0x00,
+ 0x01,0xc0, 0x70,0x00,
+ 0x00,0x3f, 0x80,0x00, // CIRC 27x27 = 6.5
+
+ 0x00,0x1f, 0xc0,0x00,
+ 0x00,0xe0, 0x38,0x00,
+ 0x01,0x00, 0x04,0x00,
+ 0x06,0x00, 0x03,0x00,
+ 0x08,0x00, 0x00,0x80,
+ 0x10,0x00, 0x00,0x40,
+ 0x10,0x00, 0x00,0x40,
+ 0x20,0x00, 0x00,0x20,
+ 0x40,0x00, 0x00,0x10,
+ 0x40,0x00, 0x00,0x10,
+ 0x40,0x00, 0x00,0x10,
+ 0x80,0x00, 0x00,0x08,
+ 0x80,0x00, 0x00,0x08,
+ 0x80,0x00, 0x00,0x08,
+ 0x80,0x00, 0x00,0x08,
+ 0x80,0x00, 0x00,0x08,
+ 0x80,0x00, 0x00,0x08,
+ 0x80,0x00, 0x00,0x08,
+ 0x40,0x00, 0x00,0x10,
+ 0x40,0x00, 0x00,0x10,
+ 0x40,0x00, 0x00,0x10,
+ 0x20,0x00, 0x00,0x20,
+ 0x10,0x00, 0x00,0x40,
+ 0x10,0x00, 0x00,0x40,
+ 0x08,0x00, 0x00,0x80,
+ 0x06,0x00, 0x03,0x00,
+ 0x01,0x00, 0x04,0x00,
+ 0x00,0xe0, 0x38,0x00,
+ 0x00,0x1f, 0xc0,0x00, // CIRC 29x29 = 7.0
+
+ // TYPE = CROSS
+
+ 0x82,
+ 0x44,
+ 0x28,
+ 0x10,
+ 0x28,
+ 0x44,
+ 0x82, // CROSS 7x7 = 1.0
+
+ 0x80,0x80,
+ 0x41,0x00,
+ 0x22,0x00,
+ 0x14,0x00,
+ 0x08,0x00,
+ 0x14,0x00,
+ 0x22,0x00,
+ 0x41,0x00,
+ 0x80,0x80, // CROSS 9x9 = 1.5
+
+ 0x80,0x20,
+ 0x40,0x40,
+ 0x20,0x80,
+ 0x11,0x00,
+ 0x0a,0x00,
+ 0x04,0x00,
+ 0x0a,0x00,
+ 0x11,0x00,
+ 0x20,0x80,
+ 0x40,0x40,
+ 0x80,0x20, // CROSS 11x11 = 2.0
+
+ 0x80,0x08,
+ 0x40,0x10,
+ 0x20,0x20,
+ 0x10,0x40,
+ 0x08,0x80,
+ 0x05,0x00,
+ 0x02,0x00,
+ 0x05,0x00,
+ 0x08,0x80,
+ 0x10,0x40,
+ 0x20,0x20,
+ 0x40,0x10,
+ 0x80,0x08, // CROSS 13x13 = 2.5
+
+ 0x80,0x02,
+ 0x40,0x04,
+ 0x20,0x08,
+ 0x10,0x10,
+ 0x08,0x20,
+ 0x04,0x40,
+ 0x02,0x80,
+ 0x01,0x00,
+ 0x02,0x80,
+ 0x04,0x40,
+ 0x08,0x20,
+ 0x10,0x10,
+ 0x20,0x08,
+ 0x40,0x04,
+ 0x80,0x02, // CROSS 15x15 = 3.0
+
+ 0x80,0x00, 0x80,
+ 0x40,0x01, 0x00,
+ 0x20,0x02, 0x00,
+ 0x10,0x04, 0x00,
+ 0x08,0x08, 0x00,
+ 0x04,0x10, 0x00,
+ 0x02,0x20, 0x00,
+ 0x01,0x40, 0x00,
+ 0x00,0x80, 0x00,
+ 0x01,0x40, 0x00,
+ 0x02,0x20, 0x00,
+ 0x04,0x10, 0x00,
+ 0x08,0x08, 0x00,
+ 0x10,0x04, 0x00,
+ 0x20,0x02, 0x00,
+ 0x40,0x01, 0x00,
+ 0x80,0x00, 0x80, // CROSS 17x17 = 3.5
+
+ 0x80,0x00, 0x20,
+ 0x40,0x00, 0x40,
+ 0x20,0x00, 0x80,
+ 0x10,0x01, 0x00,
+ 0x08,0x02, 0x00,
+ 0x04,0x04, 0x00,
+ 0x02,0x08, 0x00,
+ 0x01,0x10, 0x00,
+ 0x00,0xa0, 0x00,
+ 0x00,0x40, 0x00,
+ 0x00,0xa0, 0x00,
+ 0x01,0x10, 0x00,
+ 0x02,0x08, 0x00,
+ 0x04,0x04, 0x00,
+ 0x08,0x02, 0x00,
+ 0x10,0x01, 0x00,
+ 0x20,0x00, 0x80,
+ 0x40,0x00, 0x40,
+ 0x80,0x00, 0x20, // CROSS 19x19 = 4.0
+
+ 0x80,0x00, 0x08,
+ 0x40,0x00, 0x10,
+ 0x20,0x00, 0x20,
+ 0x10,0x00, 0x40,
+ 0x08,0x00, 0x80,
+ 0x04,0x01, 0x00,
+ 0x02,0x02, 0x00,
+ 0x01,0x04, 0x00,
+ 0x00,0x88, 0x00,
+ 0x00,0x50, 0x00,
+ 0x00,0x20, 0x00,
+ 0x00,0x50, 0x00,
+ 0x00,0x88, 0x00,
+ 0x01,0x04, 0x00,
+ 0x02,0x02, 0x00,
+ 0x04,0x01, 0x00,
+ 0x08,0x00, 0x80,
+ 0x10,0x00, 0x40,
+ 0x20,0x00, 0x20,
+ 0x40,0x00, 0x10,
+ 0x80,0x00, 0x08,/* CROSS 21x21 = 4.5 */
+
+ 0x80,0x00, 0x02,
+ 0x40,0x00, 0x04,
+ 0x20,0x00, 0x08,
+ 0x10,0x00, 0x10,
+ 0x08,0x00, 0x20,
+ 0x04,0x00, 0x40,
+ 0x02,0x00, 0x80,
+ 0x01,0x01, 0x00,
+ 0x00,0x82, 0x00,
+ 0x00,0x44, 0x00,
+ 0x00,0x28, 0x00,
+ 0x00,0x10, 0x00,
+ 0x00,0x28, 0x00,
+ 0x00,0x44, 0x00,
+ 0x00,0x82, 0x00,
+ 0x01,0x01, 0x00,
+ 0x02,0x00, 0x80,
+ 0x04,0x00, 0x40,
+ 0x08,0x00, 0x20,
+ 0x10,0x00, 0x10,
+ 0x20,0x00, 0x08,
+ 0x40,0x00, 0x04,
+ 0x80,0x00, 0x02, // CROSS 23x23 = 5.0
+
+ 0x80,0x00, 0x00,0x80,
+ 0x40,0x00, 0x01,0x00,
+ 0x20,0x00, 0x02,0x00,
+ 0x10,0x00, 0x04,0x00,
+ 0x08,0x00, 0x08,0x00,
+ 0x04,0x00, 0x10,0x00,
+ 0x02,0x00, 0x20,0x00,
+ 0x01,0x00, 0x40,0x00,
+ 0x00,0x80, 0x80,0x00,
+ 0x00,0x41, 0x00,0x00,
+ 0x00,0x22, 0x00,0x00,
+ 0x00,0x14, 0x00,0x00,
+ 0x00,0x08, 0x00,0x00,
+ 0x00,0x14, 0x00,0x00,
+ 0x00,0x22, 0x00,0x00,
+ 0x00,0x41, 0x00,0x00,
+ 0x00,0x80, 0x80,0x00,
+ 0x01,0x00, 0x40,0x00,
+ 0x02,0x00, 0x20,0x00,
+ 0x04,0x00, 0x10,0x00,
+ 0x08,0x00, 0x08,0x00,
+ 0x10,0x00, 0x04,0x00,
+ 0x20,0x00, 0x02,0x00,
+ 0x40,0x00, 0x01,0x00,
+ 0x80,0x00, 0x00,0x80, // CROSS 25x25 = 5.5
+
+ 0x80,0x00, 0x00,0x20,
+ 0x40,0x00, 0x00,0x40,
+ 0x20,0x00, 0x00,0x80,
+ 0x10,0x00, 0x01,0x00,
+ 0x08,0x00, 0x02,0x00,
+ 0x04,0x00, 0x04,0x00,
+ 0x02,0x00, 0x08,0x00,
+ 0x01,0x00, 0x10,0x00,
+ 0x00,0x80, 0x20,0x00,
+ 0x00,0x40, 0x40,0x00,
+ 0x00,0x20, 0x80,0x00,
+ 0x00,0x11, 0x00,0x00,
+ 0x00,0x0a, 0x00,0x00,
+ 0x00,0x04, 0x00,0x00,
+ 0x00,0x0a, 0x00,0x00,
+ 0x00,0x11, 0x00,0x00,
+ 0x00,0x20, 0x80,0x00,
+ 0x00,0x40, 0x40,0x00,
+ 0x00,0x80, 0x20,0x00,
+ 0x01,0x00, 0x10,0x00,
+ 0x02,0x00, 0x08,0x00,
+ 0x04,0x00, 0x04,0x00,
+ 0x08,0x00, 0x02,0x00,
+ 0x10,0x00, 0x01,0x00,
+ 0x20,0x00, 0x00,0x80,
+ 0x40,0x00, 0x00,0x40,
+ 0x80,0x00, 0x00,0x20, // CROSS 27x27 = 6.0
+
+ 0x00,0x00, 0x00,0x00,
+ 0x00,0x00, 0x00,0x00,
+ 0x20,0x00, 0x00,0x04,
+ 0x10,0x00, 0x00,0x08,
+ 0x08,0x00, 0x00,0x10,
+ 0x04,0x00, 0x00,0x20,
+ 0x02,0x00, 0x00,0x40,
+ 0x01,0x00, 0x00,0x80,
+ 0x00,0x80, 0x01,0x00,
+ 0x00,0x40, 0x02,0x00,
+ 0x00,0x20, 0x04,0x00,
+ 0x00,0x10, 0x08,0x00,
+ 0x00,0x08, 0x10,0x00,
+ 0x00,0x04, 0x20,0x00,
+ 0x00,0x02, 0x40,0x00,
+ 0x00,0x01, 0x80,0x00,
+ 0x00,0x01, 0x80,0x00,
+ 0x00,0x02, 0x40,0x00,
+ 0x00,0x04, 0x20,0x00,
+ 0x00,0x08, 0x10,0x00,
+ 0x00,0x10, 0x08,0x00,
+ 0x00,0x20, 0x04,0x00,
+ 0x00,0x40, 0x02,0x00,
+ 0x00,0x80, 0x01,0x00,
+ 0x01,0x00, 0x00,0x80,
+ 0x02,0x00, 0x00,0x40,
+ 0x04,0x00, 0x00,0x20,
+ 0x08,0x00, 0x00,0x10,
+ 0x10,0x00, 0x00,0x08,
+ 0x20,0x00, 0x00,0x04,
+ 0x00,0x00, 0x00,0x00,
+ 0x00,0x00, 0x00,0x00, // CROSS 32x32 = 6.5
+
+ 0x00,0x00, 0x00,0x00,
+ 0x40,0x00, 0x00,0x02,
+ 0x20,0x00, 0x00,0x04,
+ 0x10,0x00, 0x00,0x08,
+ 0x08,0x00, 0x00,0x10,
+ 0x04,0x00, 0x00,0x20,
+ 0x02,0x00, 0x00,0x40,
+ 0x01,0x00, 0x00,0x80,
+ 0x00,0x80, 0x01,0x00,
+ 0x00,0x40, 0x02,0x00,
+ 0x00,0x20, 0x04,0x00,
+ 0x00,0x10, 0x08,0x00,
+ 0x00,0x08, 0x10,0x00,
+ 0x00,0x04, 0x20,0x00,
+ 0x00,0x02, 0x40,0x00,
+ 0x00,0x01, 0x80,0x00,
+ 0x00,0x01, 0x80,0x00,
+ 0x00,0x02, 0x40,0x00,
+ 0x00,0x04, 0x20,0x00,
+ 0x00,0x08, 0x10,0x00,
+ 0x00,0x10, 0x08,0x00,
+ 0x00,0x20, 0x04,0x00,
+ 0x00,0x40, 0x02,0x00,
+ 0x00,0x80, 0x01,0x00,
+ 0x01,0x00, 0x00,0x80,
+ 0x02,0x00, 0x00,0x40,
+ 0x04,0x00, 0x00,0x20,
+ 0x08,0x00, 0x00,0x10,
+ 0x10,0x00, 0x00,0x08,
+ 0x20,0x00, 0x00,0x04,
+ 0x40,0x00, 0x00,0x02,
+ 0x00,0x00, 0x00,0x00 // CROSS 32x32 = 7.0
+};
+
+//! Returns a parameters for the marker of the specified type and scale.
+static void GetMarkerBitMapParam (const Aspect_TypeOfMarker theMarkerType,
+ const Standard_ShortReal& theScale,
+ Standard_Integer& theWidth,
+ Standard_Integer& theHeight,
+ Standard_Integer& theOffset,
+ Standard_Integer& theNumOfBytes)
+{
+ const Standard_Integer aType = (Standard_Integer )((theMarkerType > Aspect_TOM_O) ? Aspect_TOM_O : theMarkerType);
+ const Standard_Real anIndex = (Standard_Real )(TEL_NO_OF_SIZES - 1) * (theScale - (Standard_Real )TEL_PM_START_SIZE)
+ / (Standard_Real )(TEL_PM_END_SIZE - TEL_PM_START_SIZE);
+ Standard_Integer anId = (Standard_Integer )(anIndex + 0.5);
+ if (anId < 0)
+ {
+ anId = 0;
+ }
+ else if (anId >= TEL_NO_OF_SIZES)
+ {
+ anId = TEL_NO_OF_SIZES - 1;
+ }
+
+ theWidth = (Standard_Integer )arrPMFontInfo[aType][anId].width;
+ theHeight = (Standard_Integer )arrPMFontInfo[aType][anId].height;
+ theOffset = arrPMFontInfo[aType][anId].offset;
+ const Standard_Integer aNumOfBytesInRow = theWidth / 8 + (theWidth % 8 ? 1 : 0);
+ theNumOfBytes = theHeight * aNumOfBytesInRow;
+}
+
+//! Returns a marker image for the marker of the specified type and scale.
+static Handle(Graphic3d_MarkerImage) GetTextureImage (const Aspect_TypeOfMarker theMarkerType,
+ const Standard_ShortReal& theScale)
+{
+ Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
+ GetMarkerBitMapParam (theMarkerType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
+
+ Handle(TColStd_HArray1OfByte) aBitMap = new TColStd_HArray1OfByte (0, aNumOfBytes - 1);
+ for (Standard_Integer anIter = 0; anIter < aNumOfBytes; anIter++)
+ {
+ aBitMap->ChangeValue (anIter) = OpenGl_AspectMarker_myMarkerRaster[anOffset + anIter];
+ }
+
+ Handle(Graphic3d_MarkerImage) aTexture = new Graphic3d_MarkerImage (aBitMap, aWidth, aHeight);
+ return aTexture;
+}
+
+//! Merge two image pixmap into one. Used for creating image for following markers:
+//! Aspect_TOM_O_POINT, Aspect_TOM_O_PLUS, Aspect_TOM_O_STAR, Aspect_TOM_O_X, Aspect_TOM_RING1, Aspect_TOM_RING2, Aspect_TOM_RING3
+static Handle(Image_PixMap) MergeImages (const Handle(Image_PixMap)& theImage1,
+ const Handle(Image_PixMap)& theImage2)
+{
+ if (theImage1.IsNull() && theImage2.IsNull())
+ {
+ return Handle(Image_PixMap)();
+ }
+
+ Handle(Image_PixMap) aResultImage = new Image_PixMap();
+
+ Standard_Integer aWidth1 (0), aHeight1 (0);
+ if (!theImage1.IsNull())
+ {
+ aWidth1 = (Standard_Integer )theImage1->Width();
+ aHeight1 = (Standard_Integer )theImage1->Height();
+ }
+
+ Standard_Integer aWidth2 (0), aHeight2 (0);
+ if (!theImage2.IsNull())
+ {
+ aWidth2 = (Standard_Integer )theImage2->Width();
+ aHeight2 = (Standard_Integer )theImage2->Height();
+ }
+
+ const Standard_Integer aMaxWidth = Max (aWidth1, aWidth2);
+ const Standard_Integer aMaxHeight = Max (aHeight1, aHeight2);
+ const Standard_Integer aSize = Max (aMaxWidth, aMaxHeight);
+
+ aResultImage->InitZero (Image_Format_Alpha, aSize, aSize);
+
+ if (!theImage1.IsNull())
+ {
+ const Standard_Integer aXOffset1 = Abs (aWidth1 - aMaxWidth) / 2;
+ const Standard_Integer anYOffset1 = Abs (aHeight1 - aMaxHeight) / 2;
+ for (Standard_Integer anY = 0; anY < aHeight1; anY++)
+ {
+ Standard_Byte* anImageLine = theImage1->ChangeRow (anY);
+ Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset1 + anY);
+ for (Standard_Integer aX = 0; aX < aWidth1; aX++)
+ {
+ aResultImageLine[aXOffset1 + aX] |= anImageLine[aX];
+ }
+ }
+ }
+
+ if (!theImage2.IsNull())
+ {
+ const Standard_Integer aXOffset2 = Abs (aWidth2 - aMaxWidth) / 2;
+ const Standard_Integer anYOffset2 = Abs (aHeight2 - aMaxHeight) / 2;
+ for (Standard_Integer anY = 0; anY < aHeight2; anY++)
+ {
+ Standard_Byte* anImageLine = theImage2->ChangeRow (anY);
+ Standard_Byte* aResultImageLine = aResultImage->ChangeRow (anYOffset2 + anY);
+ for (Standard_Integer aX = 0; aX < aWidth2; aX++)
+ {
+ aResultImageLine[aXOffset2 + aX] |= anImageLine[aX];
+ }
+ }
+ }
+
+ return aResultImage;
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void OpenGl_AspectsSprite::Release (OpenGl_Context* theCtx)
+{
+ myIsSpriteReady = Standard_False;
+ if (mySprite.IsNull())
+ {
+ return;
+ }
+
+ if (theCtx != NULL)
+ {
+ if (mySprite->First()->ResourceId().IsEmpty())
+ {
+ theCtx->DelayedRelease (mySprite->ChangeFirst());
+ theCtx->DelayedRelease (mySpriteA->ChangeFirst());
+ }
+ else
+ {
+ {
+ const TCollection_AsciiString aSpriteKey = mySprite->First()->ResourceId();
+ mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
+ theCtx->ReleaseResource (aSpriteKey, Standard_True);
+ }
+ if (!mySpriteA.IsNull())
+ {
+ const TCollection_AsciiString aSpriteKeyA = mySpriteA->First()->ResourceId();
+ mySpriteA.Nullify();
+ theCtx->ReleaseResource (aSpriteKeyA, Standard_True);
+ }
+ }
+ }
+ mySprite.Nullify();
+ mySpriteA.Nullify();
+}
+
+// =======================================================================
+// function : UpdateRediness
+// purpose :
+// =======================================================================
+void OpenGl_AspectsSprite::UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect)
+{
+ // update sprite resource bindings
+ TCollection_AsciiString aSpriteKeyNew, aSpriteAKeyNew;
+ spriteKeys (theAspect->MarkerImage(), theAspect->MarkerType(), theAspect->MarkerScale(), theAspect->ColorRGBA(), aSpriteKeyNew, aSpriteAKeyNew);
+ const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
+ const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
+ if (aSpriteKeyNew.IsEmpty() || aSpriteKeyOld != aSpriteKeyNew
+ || aSpriteAKeyNew.IsEmpty() || aSpriteAKeyOld != aSpriteAKeyNew)
+ {
+ myIsSpriteReady = Standard_False;
+ myMarkerSize = theAspect->MarkerScale();
+ }
+}
+
+// =======================================================================
+// function : build
+// purpose :
+// =======================================================================
+void OpenGl_AspectsSprite::build (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_MarkerImage)& theMarkerImage,
+ Aspect_TypeOfMarker theType,
+ Standard_ShortReal theScale,
+ const Graphic3d_Vec4& theColor,
+ Standard_ShortReal& theMarkerSize)
+{
+ // generate key for shared resource
+ TCollection_AsciiString aNewKey, aNewKeyA;
+ spriteKeys (theMarkerImage, theType, theScale, theColor, aNewKey, aNewKeyA);
+
+ const TCollection_AsciiString& aSpriteKeyOld = !mySprite.IsNull() ? mySprite ->First()->ResourceId() : THE_EMPTY_KEY;
+ const TCollection_AsciiString& aSpriteAKeyOld = !mySpriteA.IsNull() ? mySpriteA->First()->ResourceId() : THE_EMPTY_KEY;
+
+ // release old shared resources
+ const Standard_Boolean aNewResource = aNewKey.IsEmpty()
+ || aSpriteKeyOld != aNewKey;
+ if (aNewResource)
+ {
+ if (!mySprite.IsNull())
+ {
+ if (mySprite->First()->ResourceId().IsEmpty())
+ {
+ theCtx->DelayedRelease (mySprite->ChangeFirst());
+ mySprite.Nullify();
+ }
+ else
+ {
+ const TCollection_AsciiString anOldKey = mySprite->First()->ResourceId();
+ mySprite.Nullify(); // we need nullify all handles before ReleaseResource() call
+ theCtx->ReleaseResource (anOldKey, Standard_True);
+ }
+ }
+ }
+ if (aNewKeyA.IsEmpty() || aSpriteAKeyOld != aNewKeyA)
+ {
+ if (!mySpriteA.IsNull())
+ {
+ if (mySpriteA->First()->ResourceId().IsEmpty())
+ {
+ theCtx->DelayedRelease (mySpriteA->ChangeFirst());
+ mySpriteA.Nullify();
+ }
+ else
+ {
+ const TCollection_AsciiString anOldKey = mySpriteA->First()->ResourceId();
+ mySpriteA.Nullify(); // we need nullify all handles before ReleaseResource() call
+ theCtx->ReleaseResource (anOldKey, Standard_True);
+ }
+ }
+ }
+
+ if (!aNewResource)
+ {
+ const OpenGl_PointSprite* aSprite = dynamic_cast<OpenGl_PointSprite*> (mySprite->First().get());
+ if (!aSprite->IsDisplayList())
+ {
+ theMarkerSize = Standard_ShortReal (Max (aSprite->SizeX(), aSprite->SizeY()));
+ }
+ return;
+ }
+ if (theType == Aspect_TOM_POINT
+ || theType == Aspect_TOM_EMPTY
+ || (theType == Aspect_TOM_USERDEFINED && theMarkerImage.IsNull()))
+ {
+ // nothing to do - just simple point
+ return;
+ }
+
+ if (mySprite.IsNull())
+ {
+ mySprite = new OpenGl_TextureSet (1);
+ mySpriteA = new OpenGl_TextureSet (1);
+ }
+
+ Handle(OpenGl_PointSprite) aSprite, aSpriteA;
+ if (!aNewKey.IsEmpty()
+ && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKeyA, aSpriteA) // alpha sprite could be shared
+ && theCtx->GetResource<Handle(OpenGl_PointSprite)> (aNewKey, aSprite))
+ {
+ // reuse shared resource
+ if (!aSprite->IsDisplayList())
+ {
+ theMarkerSize = Standard_ShortReal (Max (aSprite->SizeX(), aSprite->SizeY()));
+ }
+ mySprite ->ChangeFirst() = aSprite;
+ mySpriteA->ChangeFirst() = aSpriteA;
+ return;
+ }
+
+ const bool hadAlreadyAlpha = !aSpriteA.IsNull();
+ if (!hadAlreadyAlpha)
+ {
+ aSpriteA = new OpenGl_PointSprite (aNewKeyA);
+ }
+ aSprite = new OpenGl_PointSprite (aNewKey);
+ mySprite ->ChangeFirst() = aSprite;
+ mySpriteA->ChangeFirst() = aSpriteA;
+ if (!aNewKey.IsEmpty())
+ {
+ theCtx->ShareResource (aNewKey, aSprite);
+ if (!hadAlreadyAlpha)
+ {
+ theCtx->ShareResource (aNewKeyA, aSpriteA);
+ }
+ }
+
+ if (!theCtx.IsNull()
+ && theCtx->core20fwd != NULL
+ && !theCtx->caps->pntSpritesDisable)
+ {
+ // Creating texture resource for using it with point sprites
+ Handle(Graphic3d_MarkerImage) aNewMarkerImage;
+ Handle(Image_PixMap) anImage, anImageA;
+
+ if (theType == Aspect_TOM_USERDEFINED && !theMarkerImage.IsNull())
+ {
+ aNewMarkerImage = theMarkerImage;
+ anImage = aNewMarkerImage->GetImage();
+ }
+ else
+ {
+ // Creating image from default bitmap
+ Handle(Graphic3d_MarkerImage) aMarkerImage1, aMarkerImage2;
+
+ const Standard_ShortReal aDelta = 0.1F;
+ Standard_ShortReal aScale = theScale;
+ Standard_ShortReal aLimit = 0.0F;
+
+ switch (theType)
+ {
+ case Aspect_TOM_O_POINT:
+ {
+ // draw inner point as filled rectangle
+ const Standard_Integer aSize = theScale > 7 ? 7 : (Standard_Integer )(theScale + 0.5F);
+ Handle(TColStd_HArray1OfByte) aBitMap = fillPointBitmap (aSize);
+ aMarkerImage2 = new Graphic3d_MarkerImage (aBitMap, aSize, aSize);
+ }
+ Standard_FALLTHROUGH
+ case Aspect_TOM_O_PLUS:
+ case Aspect_TOM_O_STAR:
+ case Aspect_TOM_O_X:
+ {
+ // For this type of markers we merge two base bitmaps into one
+ // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
+ aMarkerImage1 = GetTextureImage (Aspect_TOM_O, theScale);
+ if (theType != Aspect_TOM_O_POINT)
+ {
+ aMarkerImage2 = GetTextureImage (Aspect_TypeOfMarker (theType - Aspect_TOM_O_POINT), theScale);
+ }
+ anImage = MergeImages (aMarkerImage1->GetImage(), aMarkerImage2->GetImage());
+ aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
+ break;
+ }
+ case Aspect_TOM_RING1:
+ if (aLimit == 0.0f) aLimit = aScale * 0.2f;
+ Standard_FALLTHROUGH
+ case Aspect_TOM_RING2:
+ if (aLimit == 0.0f) aLimit = aScale * 0.5f;
+ Standard_FALLTHROUGH
+ case Aspect_TOM_RING3:
+ {
+ if (aLimit == 0.0f) aLimit = aScale * 0.8f;
+ for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
+ {
+ anImage = MergeImages (anImage, GetTextureImage (Aspect_TOM_O, aScale)->GetImage());
+ }
+ aNewMarkerImage = new Graphic3d_MarkerImage (anImage);
+ break;
+ }
+ case Aspect_TOM_BALL:
+ {
+ Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
+ GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
+
+ NCollection_Vec4<Standard_Real> aColor (Standard_Real (theColor.r()),
+ Standard_Real (theColor.g()),
+ Standard_Real (theColor.b()),
+ Standard_Real (theColor.a()));
+
+ const Standard_Integer aSize = Max (aWidth + 2, aHeight + 2); // includes extra margin
+ anImage = new Image_PixMap();
+ anImageA = new Image_PixMap();
+ anImage ->InitZero (Image_Format_BGRA, aSize, aSize);
+ anImageA->InitZero (Image_Format_Alpha, aSize, aSize);
+
+ // we draw a set of circles
+ Image_ColorBGRA aColor32;
+ aColor32.a() = 255;
+ Standard_Real aHLS[3];
+ while (aScale >= 1.0f)
+ {
+ Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
+ aHLS[2] *= 0.95; // 5% saturation change
+ Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
+ aColor32.r() = Standard_Byte(255.0 * aColor.r());
+ aColor32.g() = Standard_Byte(255.0 * aColor.g());
+ aColor32.b() = Standard_Byte(255.0 * aColor.b());
+
+ const Handle(Graphic3d_MarkerImage) aMarker = GetTextureImage (Aspect_TOM_O, aScale);
+ const Handle(Image_PixMap)& aCircle = aMarker->GetImage();
+
+ const Standard_Size aDiffX = (anImage->SizeX() - aCircle->SizeX()) / 2;
+ const Standard_Size aDiffY = (anImage->SizeY() - aCircle->SizeY()) / 2;
+ for (Standard_Size aRow = 0; aRow < aCircle->SizeY(); ++aRow)
+ {
+ const Standard_Byte* aRowData = aCircle->Row (aRow);
+ for (Standard_Size aCol = 0; aCol < aCircle->SizeX(); ++aCol)
+ {
+ if (aRowData[aCol] != 0)
+ {
+ anImage ->ChangeValue<Image_ColorBGRA> (aDiffX + aRow, aDiffY + aCol) = aColor32;
+ anImageA->ChangeValue<Standard_Byte> (aDiffX + aRow, aDiffY + aCol) = 255;
+ }
+ }
+ }
+ aScale -= aDelta;
+ }
+ break;
+ }
+ default:
+ {
+ aNewMarkerImage = GetTextureImage (theType, theScale);
+ anImage = aNewMarkerImage->GetImage();
+ break;
+ }
+ }
+ }
+
+ theMarkerSize = Max ((Standard_ShortReal )anImage->Width(),(Standard_ShortReal )anImage->Height());
+
+ aSprite->Init (theCtx, *anImage.operator->(), Graphic3d_TOT_2D);
+ if (!hadAlreadyAlpha)
+ {
+ if (anImageA.IsNull()
+ && aSprite->GetFormat() != GL_ALPHA
+ && !aNewMarkerImage.IsNull())
+ {
+ anImageA = aNewMarkerImage->GetImageAlpha();
+ }
+ if (!anImageA.IsNull())
+ {
+ aSpriteA->Init (theCtx, *anImageA.operator->(), Graphic3d_TOT_2D);
+ }
+ }
+ }
+ else
+ {
+ #if !defined(GL_ES_VERSION_2_0)
+ // Creating list with bitmap for using it in compatibility mode
+ GLuint aBitmapList = glGenLists (1);
+ aSprite->SetDisplayList (theCtx, aBitmapList);
+
+ Standard_Integer aWidth, aHeight, anOffset, aNumOfBytes;
+ if (theType == Aspect_TOM_USERDEFINED && !theMarkerImage.IsNull())
+ {
+ // Reading user defined marker
+ Handle(TColStd_HArray1OfByte) aBitMap = theMarkerImage->GetBitMapArray();
+ Standard_Byte* aBitMapArray = new Standard_Byte[aBitMap->Length()];
+ theMarkerImage->GetTextureSize (aWidth, aHeight);
+
+ // We should pass bitmap to glBitmap with reversed line order as it draws it from
+ // bottom to top
+ const Standard_Integer aNumOfBytesInRow = aWidth / 8 + (aWidth % 8 ? 1 : 0);
+ const Standard_Integer anUpperIndex = aBitMap->Upper();
+ for (Standard_Integer aRow = 0; aRow < aHeight; aRow++)
+ {
+ for (Standard_Integer aByteIter = 0; aByteIter < aNumOfBytesInRow; aByteIter++)
+ {
+ aBitMapArray[aRow * aNumOfBytesInRow + aByteIter] =
+ aBitMap->Value (anUpperIndex + 1 - (aRow + 1) * aNumOfBytesInRow + aByteIter);
+ }
+ }
+
+ if (aBitMapArray != NULL)
+ {
+ glNewList (aBitmapList, GL_COMPILE);
+ glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
+ 0.f, 0.f, (const GLubyte* )aBitMapArray);
+ glEndList();
+ }
+ }
+ else
+ {
+ // Creating list for default marker
+ const Standard_ShortReal aDelta = 0.1f;
+ Standard_ShortReal aScale = theScale;
+ Standard_ShortReal aLimit = 0.0f;
+
+ glNewList (aBitmapList, GL_COMPILE);
+ switch (theType)
+ {
+ case Aspect_TOM_O_POINT:
+ {
+ // draw inner point as filled rectangle
+ const Standard_Integer aSize = theScale > 7 ? 7 : (Standard_Integer )(theScale + 0.5F);
+ Handle(TColStd_HArray1OfByte) aBitMap = fillPointBitmap (aSize);
+ glBitmap (aSize, aSize, (GLfloat )(0.5f * aSize), (GLfloat )(0.5f * aSize),
+ 0.0f, 0.0f, &aBitMap->Array1().Value (aBitMap->Lower()));
+ }
+ Standard_FALLTHROUGH
+ case Aspect_TOM_O_PLUS:
+ case Aspect_TOM_O_STAR:
+ case Aspect_TOM_O_X:
+ {
+ // For this type of markers we merge two base bitmaps into one
+ // For example Aspect_TOM_O_PLUS = Aspect_TOM_O + Aspect_TOM_PLUS
+ GetMarkerBitMapParam (Aspect_TOM_O, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
+ glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
+ 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
+ if (theType != Aspect_TOM_O_POINT)
+ {
+ GetMarkerBitMapParam (Aspect_TypeOfMarker (theType - Aspect_TOM_O_POINT), theScale, aWidth, aHeight, anOffset, aNumOfBytes);
+ glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, (GLfloat )(0.5f * aWidth), (GLfloat )(0.5f * aHeight),
+ 0.f, 0.f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
+ }
+ break;
+ }
+ case Aspect_TOM_BALL:
+ {
+ NCollection_Vec4<Standard_Real> aColor (Standard_Real (theColor.r()),
+ Standard_Real (theColor.g()),
+ Standard_Real (theColor.b()),
+ Standard_Real (theColor.a()));
+
+ // we draw a set of circles
+ while (aScale >= 1.0f)
+ {
+ Standard_Real aHLS[3];
+ Quantity_Color::RgbHls (aColor.r(), aColor.g(), aColor.b(), aHLS[0], aHLS[1], aHLS[2]);
+ // 5% saturation change
+ aHLS[2] *= 0.95;
+ Quantity_Color::HlsRgb (aHLS[0], aHLS[1], aHLS[2], aColor.r(), aColor.g(), aColor.b());
+
+ glColor4dv (aColor);
+ GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
+ glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
+ 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
+
+ aScale -= aDelta;
+ }
+ break;
+ }
+ case Aspect_TOM_RING1:
+ if (aLimit == 0.0f) aLimit = aScale * 0.2f;
+ Standard_FALLTHROUGH
+ case Aspect_TOM_RING2:
+ if (aLimit == 0.0f) aLimit = aScale * 0.5f;
+ Standard_FALLTHROUGH
+ case Aspect_TOM_RING3:
+ {
+ if (aLimit == 0.0f) aLimit = aScale * 0.8f;
+ for (; aScale > aLimit && aScale >= 1.0f; aScale -= aDelta)
+ {
+ GetMarkerBitMapParam (Aspect_TOM_O, aScale, aWidth, aHeight, anOffset, aNumOfBytes);
+ glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
+ 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
+ }
+ break;
+ }
+ default:
+ {
+ GetMarkerBitMapParam (theType, theScale, aWidth, aHeight, anOffset, aNumOfBytes);
+ glBitmap ((GLsizei )aWidth, (GLsizei )aHeight, 0.5f * GLfloat(aWidth), 0.5f * GLfloat(aHeight),
+ 0.0f, 0.0f, (const GLubyte* )&OpenGl_AspectMarker_myMarkerRaster[anOffset]);
+ break;
+ }
+ }
+ glEndList();
+ }
+ #endif
+ }
+}
+
+// =======================================================================
+// function : spriteKeys
+// purpose :
+// =======================================================================
+void OpenGl_AspectsSprite::spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
+ Aspect_TypeOfMarker theType,
+ Standard_ShortReal theScale,
+ const Graphic3d_Vec4& theColor,
+ TCollection_AsciiString& theKey,
+ TCollection_AsciiString& theKeyA)
+{
+ // generate key for shared resource
+ if (theType == Aspect_TOM_USERDEFINED)
+ {
+ if (!theMarkerImage.IsNull())
+ {
+ theKey = theMarkerImage->GetImageId();
+ theKeyA = theMarkerImage->GetImageAlphaId();
+ }
+ }
+ else if (theType != Aspect_TOM_POINT
+ && theType != Aspect_TOM_EMPTY)
+ {
+ // predefined markers are defined with 0.5 step
+ const Standard_Integer aScale = Standard_Integer(theScale * 10.0f + 0.5f);
+ theKey = TCollection_AsciiString ("OpenGl_AspectMarker") + theType + "_" + aScale;
+ theKeyA = theKey + "A";
+ if (theType == Aspect_TOM_BALL)
+ {
+ unsigned int aColor[3] =
+ {
+ (unsigned int )(255.0f * theColor.r()),
+ (unsigned int )(255.0f * theColor.g()),
+ (unsigned int )(255.0f * theColor.b())
+ };
+ char aBytes[8];
+ sprintf (aBytes, "%02X%02X%02X", aColor[0], aColor[1], aColor[2]);
+ theKey += aBytes;
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2019 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 _OpenGl_AspectsSprite_Header
+#define _OpenGl_AspectsSprite_Header
+
+#include <Graphic3d_Aspects.hxx>
+#include <Graphic3d_TextureMap.hxx>
+
+class OpenGl_Context;
+class OpenGl_TextureSet;
+
+//! OpenGl resources for custom point sprites.
+class OpenGl_AspectsSprite
+{
+public:
+ DEFINE_STANDARD_ALLOC
+public:
+ //! Empty constructor.
+ OpenGl_AspectsSprite() : myMarkerSize (1.0f), myIsSpriteReady (Standard_False) {}
+
+ Standard_ShortReal MarkerSize() const { return myMarkerSize; }
+
+ //! Return RGB sprite.
+ const Handle(OpenGl_TextureSet)& Sprite (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_Aspects)& theAspecta)
+ {
+ if (!myIsSpriteReady)
+ {
+ build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
+ myIsSpriteReady = true;
+ }
+ return mySprite;
+ }
+
+ //! Return Alpha sprite.
+ const Handle(OpenGl_TextureSet)& SpriteA (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_Aspects)& theAspecta)
+ {
+ if (!myIsSpriteReady)
+ {
+ build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
+ myIsSpriteReady = true;
+ }
+ return mySpriteA;
+ }
+
+ //! Update texture resource up-to-date state.
+ Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
+
+ //! Release texture resource.
+ Standard_EXPORT void Release (OpenGl_Context* theCtx);
+
+private:
+
+ //! Build texture resources.
+ Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_MarkerImage)& theMarkerImage,
+ Aspect_TypeOfMarker theType,
+ Standard_ShortReal theScale,
+ const Graphic3d_Vec4& theColor,
+ Standard_ShortReal& theMarkerSize);
+
+ //! Generate resource keys for a sprite.
+ static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
+ Aspect_TypeOfMarker theType,
+ Standard_ShortReal theScale,
+ const Graphic3d_Vec4& theColor,
+ TCollection_AsciiString& theKey,
+ TCollection_AsciiString& theKeyA);
+
+private:
+
+ Handle(OpenGl_TextureSet) mySprite;
+ Handle(OpenGl_TextureSet) mySpriteA;
+ Standard_ShortReal myMarkerSize;
+ Standard_Boolean myIsSpriteReady;
+
+};
+
+#endif // _OpenGl_Aspects_Header
--- /dev/null
+// Copyright (c) 2019 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.
+
+#include <OpenGl_AspectsTextureSet.hxx>
+
+#include <OpenGl_Context.hxx>
+#include <OpenGl_Sampler.hxx>
+#include <OpenGl_Texture.hxx>
+#include <OpenGl_TextureSet.hxx>
+
+#include <Graphic3d_TextureParams.hxx>
+
+#include <Image_PixMap.hxx>
+
+namespace
+{
+ static const TCollection_AsciiString THE_EMPTY_KEY;
+}
+
+// =======================================================================
+// function : Release
+// purpose :
+// =======================================================================
+void OpenGl_AspectsTextureSet::Release (OpenGl_Context* theCtx)
+{
+ if (myTextures.IsNull())
+ {
+ return;
+ }
+
+ for (OpenGl_TextureSet::Iterator aTextureIter (myTextures); aTextureIter.More(); aTextureIter.Next())
+ {
+ Handle(OpenGl_Texture)& aTextureRes = aTextureIter.ChangeValue();
+ if (aTextureRes.IsNull())
+ {
+ continue;
+ }
+
+ if (theCtx != NULL)
+ {
+ if (aTextureRes->ResourceId().IsEmpty())
+ {
+ theCtx->DelayedRelease (aTextureRes);
+ }
+ else
+ {
+ const TCollection_AsciiString aName = aTextureRes->ResourceId();
+ aTextureRes.Nullify(); // we need nullify all handles before ReleaseResource() call
+ theCtx->ReleaseResource (aName, Standard_True);
+ }
+ }
+ aTextureRes.Nullify();
+ }
+ myIsTextureReady = Standard_False;
+}
+
+// =======================================================================
+// function : UpdateRediness
+// purpose :
+// =======================================================================
+void OpenGl_AspectsTextureSet::UpdateRediness (const Handle(Graphic3d_TextureSet)& theTextures)
+{
+ const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
+ const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
+ if (aNbTexturesOld != aNbTexturesNew)
+ {
+ myIsTextureReady = Standard_False;
+ return;
+ }
+ if (aNbTexturesOld == 0)
+ {
+ return;
+ }
+
+ Graphic3d_TextureSet::Iterator aTextureIter (theTextures);
+ OpenGl_TextureSet::Iterator aResIter (myTextures);
+ for (; aResIter.More(); aResIter.Next(), aTextureIter.Next())
+ {
+ const Handle(OpenGl_Texture)& aResource = aResIter.Value();
+ const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
+ if (aTexture.IsNull() != aResource.IsNull())
+ {
+ myIsTextureReady = Standard_False;
+ return;
+ }
+ else if (aTexture.IsNull())
+ {
+ continue;
+ }
+
+ const TCollection_AsciiString& aTextureKey = aTexture->GetId();
+ if (aTextureKey.IsEmpty() || aResource->ResourceId() != aTextureKey)
+ {
+ myIsTextureReady = Standard_False;
+ return;
+ }
+ else if (aResource->Revision() != aTexture->Revision())
+ {
+ myIsTextureReady = Standard_False;
+ return;
+ }
+ else
+ {
+ // just invalidate texture parameters
+ aResource->Sampler()->SetParameters (aTexture->GetParams());
+ }
+ }
+}
+
+// =======================================================================
+// function : build
+// purpose :
+// =======================================================================
+void OpenGl_AspectsTextureSet::build (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_TextureSet)& theTextures)
+{
+ // release old texture resources
+ const Standard_Integer aNbTexturesOld = !myTextures.IsNull() ? myTextures->Size() : 0;
+ const Standard_Integer aNbTexturesNew = !theTextures.IsNull() ? theTextures->Size() : 0;
+ if (aNbTexturesOld != aNbTexturesNew)
+ {
+ Release (theCtx.get());
+ if (aNbTexturesNew > 0)
+ {
+ myTextures = new OpenGl_TextureSet (theTextures->Size());
+ }
+ else
+ {
+ myTextures.Nullify();
+ }
+ }
+ if (myTextures.IsNull())
+ {
+ return;
+ }
+
+ Graphic3d_TextureSet::Iterator aTextureIter (theTextures);
+ OpenGl_TextureSet::Iterator aResIter (myTextures);
+ for (; aResIter.More(); aResIter.Next(), aTextureIter.Next())
+ {
+ Handle(OpenGl_Texture)& aResource = aResIter.ChangeValue();
+ const Handle(Graphic3d_TextureMap)& aTexture = aTextureIter.Value();
+ if (!aResource.IsNull())
+ {
+ if (!aTexture.IsNull()
+ && aTexture->GetId() == aResource->ResourceId()
+ && aTexture->Revision() != aResource->Revision())
+ {
+ if (Handle(Image_PixMap) anImage = aTexture->GetImage())
+ {
+ aResource->Sampler()->SetParameters (aTexture->GetParams());
+ aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
+ aResource->SetRevision (aTexture->Revision());
+ continue;
+ }
+ }
+
+ if (aResource->ResourceId().IsEmpty())
+ {
+ theCtx->DelayedRelease (aResource);
+ aResource.Nullify();
+ }
+ else
+ {
+ const TCollection_AsciiString aTextureKey = aResource->ResourceId();
+ aResource.Nullify(); // we need nullify all handles before ReleaseResource() call
+ theCtx->ReleaseResource (aTextureKey, Standard_True);
+ }
+ }
+
+ if (!aTexture.IsNull())
+ {
+ const TCollection_AsciiString& aTextureKeyNew = aTexture->GetId();
+ if (aTextureKeyNew.IsEmpty()
+ || !theCtx->GetResource<Handle(OpenGl_Texture)> (aTextureKeyNew, aResource))
+ {
+ aResource = new OpenGl_Texture (aTextureKeyNew, aTexture->GetParams());
+ if (Handle(Image_PixMap) anImage = aTexture->GetImage())
+ {
+ aResource->Init (theCtx, *anImage.operator->(), aTexture->Type());
+ aResource->SetRevision (aTexture->Revision());
+ }
+ if (!aTextureKeyNew.IsEmpty())
+ {
+ theCtx->ShareResource (aTextureKeyNew, aResource);
+ }
+ }
+ else
+ {
+ aResource->Sampler()->SetParameters (aTexture->GetParams());
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2019 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 _OpenGl_AspectsTextureSet_Header
+#define _OpenGl_AspectsTextureSet_Header
+
+#include <Graphic3d_TextureMap.hxx>
+#include <Graphic3d_TextureSet.hxx>
+
+class OpenGl_Context;
+class OpenGl_TextureSet;
+
+//! OpenGl resources for custom textures.
+class OpenGl_AspectsTextureSet
+{
+public:
+ DEFINE_STANDARD_ALLOC
+public:
+ //! Empty constructor.
+ OpenGl_AspectsTextureSet() : myIsTextureReady (Standard_False) {}
+
+ //! Return textures array.
+ const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_TextureSet)& theTextures)
+ {
+ if (!myIsTextureReady)
+ {
+ build (theCtx, theTextures);
+ myIsTextureReady = true;
+ }
+ return myTextures;
+ }
+
+ //! Update texture resource up-to-date state.
+ Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_TextureSet)& theTextures);
+
+ //! Release texture resource.
+ Standard_EXPORT void Release (OpenGl_Context* theCtx);
+
+private:
+
+ //! Build texture resource.
+ Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
+ const Handle(Graphic3d_TextureSet)& theTextures);
+
+private:
+
+ Handle(OpenGl_TextureSet) myTextures;
+ Standard_Boolean myIsTextureReady;
+
+};
+
+#endif // _OpenGl_AspectsTextureSet_Header
// Get texture parameters
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
- const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace();
+ const OpenGl_Aspects* anAspectFace = theWorkspace->Aspects();
GLfloat aTextureWidth = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeX();
GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureSet (aCtx)->First()->SizeY();
#include <Aspect_GradientFillMethod.hxx>
#include <Aspect_FillMethod.hxx>
#include <Graphic3d_TypeOfBackground.hxx>
-#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Vec.hxx>
#include <OpenGl_Workspace.hxx>
theStencilSentry.Init();
// check if capping plane should be rendered within current pass (only opaque / only transparent)
- const OpenGl_AspectFace* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->AspectFace() : NULL;
- thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_AspectFillArea3d)());
- theWorkspace->SetAspectFace (thePlane->AspectFace());
+ const OpenGl_Aspects* anObjAspectFace = aRenderPlane->ToUseObjectProperties() ? aGroupIter.Value()->GlAspects() : NULL;
+ thePlane->Update (aContext, anObjAspectFace != NULL ? anObjAspectFace->Aspect() : Handle(Graphic3d_Aspects)());
+ theWorkspace->SetAspects (thePlane->AspectFace());
theWorkspace->SetRenderFilter (aPrevFilter);
if (!theWorkspace->ShouldRender (&thePlane->Primitives()))
{
const bool aColorMaskBack = aContext->SetColorMask (false);
// override aspects, disable culling
- theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
- theWorkspace->ApplyAspectFace();
+ theWorkspace->SetAspects (&theWorkspace->NoneCulling());
+ theWorkspace->ApplyAspects();
// evaluate number of pair faces
if (theWorkspace->UseZBuffer())
}
// override material, cull back faces
- theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
- theWorkspace->ApplyAspectFace();
+ theWorkspace->SetAspects (&theWorkspace->FrontCulling());
+ theWorkspace->ApplyAspects();
// enable all clip plane except the rendered one
aContext->ChangeClipping().EnableAllExcept (theClipChain, theSubPlaneIndex);
glEnable (GL_DEPTH_TEST);
}
- theWorkspace->SetAspectFace (thePlane->AspectFace());
+ theWorkspace->SetAspects (thePlane->AspectFace());
renderPlane (theWorkspace, thePlane);
// turn on the current plane to restore initial state
}
// remember current aspect face defined in workspace
- const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
+ const OpenGl_Aspects* aFaceAsp = theWorkspace->Aspects();
// only filled primitives should be rendered
const Standard_Integer aPrevFilter = theWorkspace->RenderFilter();
}
// restore rendering aspects
- theWorkspace->SetAspectFace (aFaceAsp);
+ theWorkspace->SetAspects (aFaceAsp);
theWorkspace->SetRenderFilter (aPrevFilter);
}
// purpose :
// =======================================================================
void OpenGl_CappingPlaneResource::Update (const Handle(OpenGl_Context)& ,
- const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
+ const Handle(Graphic3d_Aspects)& theObjAspect)
{
updateTransform();
updateAspect (theObjAspect);
// function : updateAspect
// purpose :
// =======================================================================
-void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect)
+void OpenGl_CappingPlaneResource::updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect)
{
if (myAspect == NULL)
{
- myAspect = new OpenGl_AspectFace();
+ myAspect = new OpenGl_Aspects();
myAspectMod = myPlaneRoot->MCountAspect() - 1; // mark out of sync
}
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Resource.hxx>
-#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Matrix.hxx>
#include <Graphic3d_ClipPlane.hxx>
//! @param theContext [in] the context
//! @param theObjAspect [in] object aspect
Standard_EXPORT void Update (const Handle(OpenGl_Context)& theContext,
- const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
+ const Handle(Graphic3d_Aspects)& theObjAspect);
//! Release associated OpenGl resources.
//! @param theContext [in] the resource context.
const Handle(Graphic3d_ClipPlane)& Plane() const { return myPlaneRoot; }
//! @return aspect face for rendering capping surface.
- inline const OpenGl_AspectFace* AspectFace() const { return myAspect; }
+ inline const OpenGl_Aspects* AspectFace() const { return myAspect; }
//! @return evaluated orientation matrix to transform infinite plane.
inline const OpenGl_Matrix* Orientation() const { return &myOrientation; }
void updateTransform();
//! Update resources.
- void updateAspect (const Handle(Graphic3d_AspectFillArea3d)& theObjAspect);
+ void updateAspect (const Handle(Graphic3d_Aspects)& theObjAspect);
private:
OpenGl_PrimitiveArray myPrimitives; //!< vertices and texture coordinates for rendering
OpenGl_Matrix myOrientation; //!< plane transformation matrix.
- OpenGl_AspectFace* myAspect; //!< capping face aspect.
+ OpenGl_Aspects* myAspect; //!< capping face aspect.
Handle(Graphic3d_ClipPlane) myPlaneRoot; //!< parent clipping plane structure.
- Handle(Graphic3d_AspectFillArea3d) myFillAreaAspect; //!< own capping aspect
+ Handle(Graphic3d_Aspects) myFillAreaAspect;//!< own capping aspect
unsigned int myEquationMod; //!< modification counter for plane equation.
unsigned int myAspectMod; //!< modification counter for aspect.
#include <OpenGl_Sampler.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_Workspace.hxx>
-#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_Aspects.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <Graphic3d_RenderingParams.hxx>
// function : SetShadingMaterial
// purpose :
// =======================================================================
-void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
+void OpenGl_Context::SetShadingMaterial (const OpenGl_Aspects* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
{
- const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
- ? theHighlight->BasicFillAreaAspect()
- : theAspect->Aspect();
+ const Handle(Graphic3d_Aspects)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
+ ? (const Handle(Graphic3d_Aspects)& )theHighlight->BasicFillAreaAspect()
+ : theAspect->Aspect();
const bool toDistinguish = anAspect->Distinguish();
const bool toMapTexture = anAspect->ToMapTexture();
// function : CheckIsTransparent
// purpose :
// =======================================================================
-Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_AspectFace* theAspect,
+Standard_Boolean OpenGl_Context::CheckIsTransparent (const OpenGl_Aspects* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
Standard_ShortReal& theAlphaFront,
Standard_ShortReal& theAlphaBack)
{
- const Handle(Graphic3d_AspectFillArea3d)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
- ? theHighlight->BasicFillAreaAspect()
- : theAspect->Aspect();
+ const Handle(Graphic3d_Aspects)& anAspect = (!theHighlight.IsNull() && !theHighlight->BasicFillAreaAspect().IsNull())
+ ? (const Handle(Graphic3d_Aspects)& )theHighlight->BasicFillAreaAspect()
+ : theAspect->Aspect();
const bool toDistinguish = anAspect->Distinguish();
const Graphic3d_MaterialAspect& aMatFrontSrc = anAspect->FrontMaterial();
typedef OpenGl_TmplCore44<OpenGl_GlCore43> OpenGl_GlCore44;
class Graphic3d_PresentationAttributes;
-class OpenGl_AspectFace;
+class OpenGl_Aspects;
class OpenGl_FrameBuffer;
class OpenGl_Sampler;
class OpenGl_ShaderProgram;
Standard_EXPORT Standard_Boolean BindProgram (const Handle(OpenGl_ShaderProgram)& theProgram);
//! Setup current shading material.
- Standard_EXPORT void SetShadingMaterial (const OpenGl_AspectFace* theAspect,
+ Standard_EXPORT void SetShadingMaterial (const OpenGl_Aspects* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight);
//! Checks if transparency is required for the given aspect and highlight style.
- Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
+ Standard_EXPORT static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight,
Standard_ShortReal& theAlphaFront,
Standard_ShortReal& theAlphaBack);
//! Checks if transparency is required for the given aspect and highlight style.
- static Standard_Boolean CheckIsTransparent (const OpenGl_AspectFace* theAspect,
+ static Standard_Boolean CheckIsTransparent (const OpenGl_Aspects* theAspect,
const Handle(Graphic3d_PresentationAttributes)& theHighlight)
{
Standard_ShortReal anAlphaFront = 1.0f, anAlphaBack = 1.0f;
glDepthMask (GL_FALSE);
}
- const OpenGl_AspectText* aTextAspectBack = theWorkspace->SetAspectText (&myTextAspect);
+ const OpenGl_Aspects* aTextAspectBack = theWorkspace->SetAspects (&myTextAspect);
aCtx->ModelWorldState.Push();
aCtx->ModelWorldState.ChangeCurrent().InitIdentity();
aCtx->ModelWorldState.Pop();
aCtx->ApplyWorldViewMatrix();
- theWorkspace->SetAspectText (aTextAspectBack);
+ theWorkspace->SetAspects (aTextAspectBack);
if (theWorkspace->UseDepthWrite() != wasEnabledDepth)
{
theWorkspace->UseDepthWrite() = wasEnabledDepth;
Handle(OpenGl_FrameStats) myStatsPrev; //!< currently displayed stats
Handle(Graphic3d_TransformPers) myCountersTrsfPers; //!< transformation persistence for counters presentation
OpenGl_Text myCountersText; //!< counters presentation
- OpenGl_AspectText myTextAspect; //!< text aspect
+ OpenGl_Aspects myTextAspect; //!< text aspect
Handle(Graphic3d_TransformPers) myChartTrsfPers; //!< transformation persistence for chart presentation
Handle(Graphic3d_ArrayOfTriangles) myChartArray; //!< array of chart triangles
Handle(OpenGl_VertexBuffer) myChartVertices; //!< VBO with chart triangles
#include <Graphic3d_TransformPers.hxx>
#include <Graphic3d_TransformUtils.hxx>
#include <gp_Ax3.hxx>
-#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Workspace.hxx>
#include <OpenGl_View.hxx>
#include <Precision.hxx>
myLabelValues.SetFontSize (theCtx, myData.ValuesSize());
myAspectLabels.Aspect()->SetTextFontAspect (myData.NamesFontAspect());
- myAspectLabels.Aspect()->SetFont (myData.NamesFont());
+ myAspectLabels.Aspect()->SetTextFont (!myData.NamesFont().IsEmpty()
+ ? new TCollection_HAsciiString (myData.NamesFont())
+ : Handle(TCollection_HAsciiString )());
myAspectValues.Aspect()->SetTextFontAspect (myData.ValuesFontAspect());
- myAspectValues.Aspect()->SetFont (myData.ValuesFont());
+ myAspectValues.Aspect()->SetTextFont (!myData.ValuesFont().IsEmpty()
+ ? new TCollection_HAsciiString (myData.ValuesFont())
+ : Handle(TCollection_HAsciiString )());
// Grid aspect
myGridLineAspect.Aspect()->SetColor (myData.GridColor());
{
const Axis& anAxis = myAxes[theIndex];
- theWorkspace->SetAspectLine (&anAxis.LineAspect);
+ theWorkspace->SetAspects (&anAxis.LineAspect);
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
// Reset transformations
if (aCurAspect.ToDrawTickmarks() && aCurAspect.TickmarksNumber() > 0)
{
- theWorkspace->SetAspectLine (&myGridLineAspect);
+ theWorkspace->SetAspects (&myGridLineAspect);
OpenGl_Mat4 aModelMat (theMat);
OpenGl_Vec3 aMiddle (theGridAxes.Ticks[theIndex] + aSizeVec * theGridAxes.Axes[theIndex] * 0.5f + aDir * (Standard_ShortReal)(theDpix * anOffset));
myAspectLabels.Aspect()->SetColor (anAxis.NameColor);
- theWorkspace->SetAspectText (&myAspectLabels);
+ theWorkspace->SetAspects (&myAspectLabels);
anAxis.Label.SetPosition (aMiddle);
anAxis.Label.Render (theWorkspace);
}
if (aCurAspect.ToDrawValues() && aCurAspect.TickmarksNumber() > 0)
{
myAspectValues.Aspect()->SetColor (anAxis.LineAspect.Aspect()->Color());
- theWorkspace->SetAspectText (&myAspectValues);
+ theWorkspace->SetAspects (&myAspectValues);
Standard_Real anOffset = aCurAspect.ValuesOffset() + aCurAspect.TickmarksLength();
for (Standard_Integer anIt = 0; anIt <= aCurAspect.TickmarksNumber(); ++anIt)
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
// Remember current aspects
- const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine();
- const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText();
+ const OpenGl_Aspects* anOldAspectLine = theWorkspace->Aspects();
OpenGl_Mat4 aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
if (myData.ToDrawGrid())
{
- theWorkspace->SetAspectLine (&myGridLineAspect);
+ theWorkspace->SetAspects (&myGridLineAspect);
// render grid edges
if (anAxesState & XOO_XYO)
renderTickmarkLabels (theWorkspace, aModelMatrix, anIter, aGridAxes, aDpix);
}
- theWorkspace->SetAspectLine (anOldAspectLine);
- theWorkspace->SetAspectText (anOldAspectText);
+ theWorkspace->SetAspects (anOldAspectLine);
aContext->WorldViewState.Pop();
aContext->ApplyWorldViewMatrix();
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <NCollection_Array1.hxx>
-#include <OpenGl_AspectLine.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Text.hxx>
OpenGl_Vec3 Direction;
Quantity_Color NameColor;
- OpenGl_AspectLine LineAspect;
+ OpenGl_Aspects LineAspect;
mutable OpenGl_Text Label;
mutable OpenGl_PrimitiveArray Tickmark;
mutable OpenGl_PrimitiveArray Line;
mutable Axis myAxes[3]; //!< Axes for trihedron
mutable Graphic3d_GraduatedTrihedron myData;
- mutable OpenGl_AspectLine myGridLineAspect; //!< Color grid properties
+ mutable OpenGl_Aspects myGridLineAspect; //!< Color grid properties
protected: //! @name Labels properties
- mutable OpenGl_Text myLabelValues;
- mutable OpenGl_AspectText myAspectLabels;
- mutable OpenGl_AspectText myAspectValues;
+ mutable OpenGl_Text myLabelValues;
+ mutable OpenGl_Aspects myAspectLabels;
+ mutable OpenGl_Aspects myAspectValues;
private:
const Standard_ShortReal aHeight = (theHeight < 2.0f) ? DefaultTextHeight() : theHeight;
OpenGl_TextParam aTextParam;
aTextParam.Height = (int )aHeight;
- OpenGl_AspectText aTextAspect;
- aTextAspect.Aspect()->SetSpace (0.3);
+ OpenGl_Aspects aTextAspect;
TCollection_ExtendedString anExtText = theText;
NCollection_String aText (anExtText.ToExtString());
OpenGl_Text::StringSize(aCtx, aText, aTextAspect, aTextParam, theView->RenderingParams().Resolution, theWidth, theAscent, theDescent);
// =======================================================================
OpenGl_Group::OpenGl_Group (const Handle(Graphic3d_Structure)& theStruct)
: Graphic3d_Group (theStruct),
- myAspectLine(NULL),
- myAspectFace(NULL),
- myAspectMarker(NULL),
- myAspectText(NULL),
+ myAspects(NULL),
myFirst(NULL),
myLast(NULL),
myIsRaytracable (Standard_False)
// function : SetGroupPrimitivesAspect
// purpose :
// =======================================================================
-void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
+void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect)
{
if (IsDeleted())
{
return;
}
- if (myAspectLine == NULL)
+ if (myAspects == NULL)
{
- myAspectLine = new OpenGl_AspectLine (theAspect);
+ myAspects = new OpenGl_Aspects (theAspect);
}
else
{
- myAspectLine->SetAspect (theAspect);
- }
- Update();
-}
-
-// =======================================================================
-// function : SetPrimitivesAspect
-// purpose :
-// =======================================================================
-void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect)
-{
- if (myAspectLine == NULL)
- {
- SetGroupPrimitivesAspect (theAspect);
- return;
- }
- else if (IsDeleted())
- {
- return;
- }
-
- OpenGl_AspectLine* anAspectLine = new OpenGl_AspectLine (theAspect);
- AddElement (anAspectLine);
- Update();
-}
-
-// =======================================================================
-// function : SetGroupPrimitivesAspect
-// purpose :
-// =======================================================================
-void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
-{
- if (IsDeleted())
- {
- return;
+ myAspects->SetAspect (theAspect);
}
- if (myAspectFace == NULL)
+ if (OpenGl_Structure* aStruct = myIsRaytracable ? GlStruct() : NULL)
{
- myAspectFace = new OpenGl_AspectFace (theAspect);
- }
- else
- {
- myAspectFace->SetAspect (theAspect);
- }
-
- if (myIsRaytracable)
- {
- OpenGl_Structure* aStruct = GlStruct();
- if (aStruct != NULL)
- {
- aStruct->UpdateStateIfRaytracable (Standard_False);
- }
+ aStruct->UpdateStateIfRaytracable (Standard_False);
}
Update();
// function : SetPrimitivesAspect
// purpose :
// =======================================================================
-void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
+void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect)
{
- if (myAspectFace == NULL)
+ if (myAspects == NULL)
{
SetGroupPrimitivesAspect (theAspect);
return;
return;
}
- OpenGl_AspectFace* anAspectFace = new OpenGl_AspectFace (theAspect);
- AddElement (anAspectFace);
- Update();
-}
-
-// =======================================================================
-// function : SetGroupPrimitivesAspect
-// purpose :
-// =======================================================================
-void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
-{
- if (IsDeleted())
- {
- return;
- }
-
- if (myAspectMarker == NULL)
- {
- myAspectMarker = new OpenGl_AspectMarker (theAspMarker);
- }
- else
- {
- myAspectMarker->SetAspect (theAspMarker);
- }
+ OpenGl_Aspects* anAspects = new OpenGl_Aspects (theAspect);
+ AddElement (anAspects);
Update();
}
// =======================================================================
-// function : SetPrimitivesAspect
-// purpose :
-// =======================================================================
-void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspMarker)
-{
- if (myAspectMarker == NULL)
- {
- SetGroupPrimitivesAspect (theAspMarker);
- return;
- }
- else if (IsDeleted())
- {
- return;
- }
-
- OpenGl_AspectMarker* anAspectMarker = new OpenGl_AspectMarker (theAspMarker);
- AddElement (anAspectMarker);
- Update();
-}
-
-// =======================================================================
-// function : SetGroupPrimitivesAspect
+// function : SynchronizeAspects
// purpose :
// =======================================================================
-void OpenGl_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
+void OpenGl_Group::SynchronizeAspects()
{
- if (IsDeleted())
- {
- return;
- }
-
- if (myAspectText == NULL)
+ if (myAspects != NULL)
{
- myAspectText = new OpenGl_AspectText (theAspText);
+ myAspects->SynchronizeAspects();
+ if (OpenGl_Structure* aStruct = myIsRaytracable ? GlStruct() : NULL)
+ {
+ aStruct->UpdateStateIfRaytracable (Standard_False);
+ }
}
- else
+ for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
{
- myAspectText->SetAspect (theAspText);
+ aNode->elem->SynchronizeAspects();
}
- Update();
}
// =======================================================================
-// function : SetPrimitivesAspect
+// function : ReplaceAspects
// purpose :
// =======================================================================
-void OpenGl_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspText)
+void OpenGl_Group::ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap)
{
- if (myAspectText == NULL)
- {
- SetGroupPrimitivesAspect (theAspText);
- return;
- }
- else if (IsDeleted())
+ if (theMap.IsEmpty())
{
return;
}
- OpenGl_AspectText* anAspectText = new OpenGl_AspectText (theAspText);
- AddElement (anAspectText);
- Update();
-}
-
-// =======================================================================
-// function : SynchronizeAspects
-// purpose :
-// =======================================================================
-void OpenGl_Group::SynchronizeAspects()
-{
- if (myAspectFace != NULL)
- {
- myAspectFace->SynchronizeAspects();
- }
- if (myAspectLine != NULL)
- {
- myAspectLine->SynchronizeAspects();
- }
- if (myAspectMarker != NULL)
- {
- myAspectMarker->SynchronizeAspects();
- }
- if (myAspectText != NULL)
+ Handle(Graphic3d_Aspects) anAspect;
+ if (myAspects != NULL
+ && theMap.Find (myAspects->Aspect(), anAspect))
{
- myAspectText->SynchronizeAspects();
+ myAspects->SetAspect (anAspect);
+ if (OpenGl_Structure* aStruct = myIsRaytracable ? GlStruct() : NULL)
+ {
+ aStruct->UpdateStateIfRaytracable (Standard_False);
+ }
}
for (OpenGl_ElementNode* aNode = myFirst; aNode != NULL; aNode = aNode->next)
{
- aNode->elem->SynchronizeAspects();
+ OpenGl_Aspects* aGlAspect = dynamic_cast<OpenGl_Aspects*> (aNode->elem);
+ if (aGlAspect != NULL
+ && theMap.Find (aGlAspect->Aspect(), anAspect))
+ {
+ aGlAspect->SetAspect (anAspect);
+ }
}
}
// Setup aspects
theWorkspace->SetAllowFaceCulling (myIsClosed
&& !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn());
- const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine();
- const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace();
- const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker();
- const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText();
- const bool isLineSet = myAspectLine && renderFiltered (theWorkspace, myAspectLine);
- const bool isFaceSet = myAspectFace && renderFiltered (theWorkspace, myAspectFace);
- const bool isMarkerSet = myAspectMarker && renderFiltered (theWorkspace, myAspectMarker);
- const bool isTextSet = myAspectText && renderFiltered (theWorkspace, myAspectText);
+ const OpenGl_Aspects* aBackAspects = theWorkspace->Aspects();
+ const bool isAspectSet = myAspects != NULL && renderFiltered (theWorkspace, myAspects);
// Render group elements
for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next)
}
// Restore aspects
- if (isLineSet)
- theWorkspace->SetAspectLine (aBackAspectLine);
- if (isFaceSet)
- theWorkspace->SetAspectFace (aBackAspectFace);
- if (isMarkerSet)
- theWorkspace->SetAspectMarker (aBackAspectMarker);
- if (isTextSet)
- theWorkspace->SetAspectText (aBackAspectText);
+ if (isAspectSet)
+ theWorkspace->SetAspects (aBackAspects);
}
// =======================================================================
}
myLast = NULL;
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectLine);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectFace);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectMarker);
- OpenGl_Element::Destroy (theGlCtx.operator->(), myAspectText);
+ OpenGl_Element::Destroy (theGlCtx.operator->(), myAspects);
}
#include <Graphic3d_Structure.hxx>
#include <NCollection_List.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Element.hxx>
class OpenGl_Group;
Standard_EXPORT virtual void Clear (const Standard_Boolean theToUpdateStructureMgr) Standard_OVERRIDE;
//! Return line aspect.
- virtual Handle(Graphic3d_AspectLine3d) LineAspect() const Standard_OVERRIDE
+ virtual Handle(Graphic3d_Aspects) Aspects() const Standard_OVERRIDE
{
- return myAspectLine != NULL
- ? myAspectLine->Aspect()
- : Handle(Graphic3d_AspectLine3d)();
+ return myAspects != NULL
+ ? myAspects->Aspect()
+ : Handle(Graphic3d_Aspects)();
}
- //! Update line aspect.
- Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) Standard_OVERRIDE;
+ //! Update aspect.
+ Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
- //! Append line aspect as an element.
- Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& theAspect) Standard_OVERRIDE;
-
- //! Return marker aspect.
- virtual Handle(Graphic3d_AspectMarker3d) MarkerAspect() const Standard_OVERRIDE
- {
- return myAspectMarker != NULL
- ? myAspectMarker->Aspect()
- : Handle(Graphic3d_AspectMarker3d)();
- }
-
- //! Update marker aspect.
- Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) Standard_OVERRIDE;
-
- //! Append marker aspect as an element.
- Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& theAspect) Standard_OVERRIDE;
-
- //! Return fill area aspect.
- virtual Handle(Graphic3d_AspectFillArea3d) FillAreaAspect() const Standard_OVERRIDE
- {
- return myAspectFace != NULL
- ? myAspectFace->Aspect()
- : Handle(Graphic3d_AspectFillArea3d)();
- }
-
- //! Update face aspect.
- Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) Standard_OVERRIDE;
-
- //! Append face aspect as an element.
- Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& theAspect) Standard_OVERRIDE;
-
- //! Return marker aspect.
- virtual Handle(Graphic3d_AspectText3d) TextAspect() const Standard_OVERRIDE
- {
- return myAspectText != NULL
- ? myAspectText->Aspect()
- : Handle(Graphic3d_AspectText3d)();
- }
-
- //! Update text aspect.
- Standard_EXPORT virtual void SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE;
-
- //! Append text aspect as an element.
- Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& theAspect) Standard_OVERRIDE;
+ //! Append aspect as an element.
+ Standard_EXPORT virtual void SetPrimitivesAspect (const Handle(Graphic3d_Aspects)& theAspect) Standard_OVERRIDE;
//! Update presentation aspects after their modification.
Standard_EXPORT virtual void SynchronizeAspects() Standard_OVERRIDE;
+ //! Replace aspects specified in the replacement map.
+ Standard_EXPORT virtual void ReplaceAspects (const Graphic3d_MapOfAspectsToAspects& theMap) Standard_OVERRIDE;
+
//! Add primitive array element
Standard_EXPORT virtual void AddPrimitiveArray (const Graphic3d_TypeOfPrimitiveArray theType,
const Handle(Graphic3d_IndexBuffer)& theIndices,
//! Returns first OpenGL element node of the group.
const OpenGl_ElementNode* FirstNode() const { return myFirst; }
- //! Returns OpenGL face aspect.
- const OpenGl_AspectFace* AspectFace() const { return myAspectFace; }
+ //! Returns OpenGL aspect.
+ const OpenGl_Aspects* GlAspects() const { return myAspects; }
//! Is the group ray-tracable (contains ray-tracable elements)?
Standard_Boolean IsRaytracable() const { return myIsRaytracable; }
protected:
- OpenGl_AspectLine* myAspectLine;
- OpenGl_AspectFace* myAspectFace;
- OpenGl_AspectMarker* myAspectMarker;
- OpenGl_AspectText* myAspectText;
-
- OpenGl_ElementNode* myFirst;
- OpenGl_ElementNode* myLast;
-
- Standard_Boolean myIsRaytracable;
+ OpenGl_Aspects* myAspects;
+ OpenGl_ElementNode* myFirst;
+ OpenGl_ElementNode* myLast;
+ Standard_Boolean myIsRaytracable;
public:
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_IndexBuffer.hxx>
// function : drawEdges
// purpose :
// =======================================================================
-void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeColour,
- const Handle(OpenGl_Workspace)& theWorkspace) const
+void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorkspace) const
{
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
if (myVboAttribs.IsNull())
return;
}
- const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
- const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
+ const OpenGl_Aspects* anAspect = theWorkspace->Aspects();
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
#endif
if (aGlContext->core20fwd != NULL)
{
- aGlContext->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), anAspect->Aspect()->Type(),
+ aGlContext->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), anAspect->Aspect()->EdgeLineType(),
Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, Standard_False,
anAspect->ShaderProgramRes (aGlContext));
}
+ aGlContext->SetSampleAlphaToCoverage (aGlContext->ShaderManager()->MaterialState().HasAlphaCutoff());
const GLenum aDrawMode = !aGlContext->ActiveProgram().IsNull()
&& aGlContext->ActiveProgram()->HasTessellationStage()
? GL_PATCHES
/// 3) draw primitive's edges by vertexes if no edges and bounds array is specified
myVboAttribs->BindPositionAttribute (aGlContext);
- aGlContext->SetColor4fv (theEdgeColour);
- aGlContext->SetTypeOfLine (anAspect->Aspect()->Type());
- aGlContext->SetLineWidth (anAspect->Aspect()->Width());
+ aGlContext->SetColor4fv (theWorkspace->EdgeColor().a() >= 0.1f
+ ? theWorkspace->EdgeColor()
+ : theWorkspace->View()->BackgroundColor());
+ aGlContext->SetTypeOfLine (anAspect->Aspect()->EdgeLineType());
+ aGlContext->SetLineWidth (anAspect->Aspect()->EdgeWidth());
if (!myVboIndices.IsNull())
{
myVboAttribs->UnbindAttribute (aGlContext, Graphic3d_TOA_POS);
// restore line context
- theWorkspace->SetAspectLine (anAspectLineOld);
#if !defined(GL_ES_VERSION_2_0)
aGlContext->SetPolygonMode (aPolyModeOld);
#endif
// =======================================================================
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
{
- const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
+ const OpenGl_Aspects* anAspectMarker = theWorkspace->Aspects();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const GLenum aDrawMode = !aCtx->ActiveProgram().IsNull()
&& aCtx->ActiveProgram()->HasTessellationStage()
aCtx->SetPointSize (1.0f);
return;
}
- else if (anAspectMarker->Aspect()->Type() == Aspect_TOM_POINT)
+ else if (anAspectMarker->Aspect()->MarkerType() == Aspect_TOM_POINT)
{
aCtx->SetPointSize (anAspectMarker->MarkerSize());
aCtx->core11fwd->glDrawArrays (aDrawMode, 0, !myVboAttribs.IsNull() ? myVboAttribs->GetElemsNb() : myAttribs->NbElements);
}
#if !defined(GL_ES_VERSION_2_0)
// Textured markers will be drawn with the glBitmap
- else if (anAspectMarker->Aspect()->Type() != Aspect_TOM_POINT
+ else if (anAspectMarker->Aspect()->MarkerType() != Aspect_TOM_POINT
&& aSpriteNorm != NULL)
{
/**if (!isHilight && (myPArray->vcolours != NULL))
return;
}
- const OpenGl_AspectFace* anAspectFace = theWorkspace->ApplyAspectFace();
- const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
- const OpenGl_AspectMarker* anAspectMarker = myDrawMode == GL_POINTS
- ? theWorkspace->ApplyAspectMarker()
- : theWorkspace->AspectMarker();
-
+ const OpenGl_Aspects* anAspectFace = theWorkspace->ApplyAspects();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
Handle(OpenGl_TextureSet) aTextureBack;
{
if (myDrawMode == GL_POINTS)
{
- if (anAspectMarker->Aspect()->Type() == Aspect_TOM_EMPTY)
+ if (anAspectFace->Aspect()->MarkerType() == Aspect_TOM_EMPTY)
{
return;
}
}
else
{
- if (anAspectLine->Aspect()->Type() == Aspect_TOL_EMPTY)
+ if (anAspectFace->Aspect()->LineType() == Aspect_TOL_EMPTY)
{
return;
}
Standard_Boolean toKeepData = Standard_False;
if (myDrawMode == GL_POINTS)
{
- const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
+ const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
toKeepData = aSpriteNorm != NULL
&& aSpriteNorm->IsDisplayList();
case GL_POINTS:
{
aShadingModel = aCtx->ShaderManager()->ChooseMarkerShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
- const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
+ const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectFace->SpriteRes (aCtx);
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
if (aSpriteNorm != NULL
&& !aSpriteNorm->IsDisplayList())
{
- const Handle(OpenGl_TextureSet)& aSprite = toHilight && anAspectMarker->SpriteHighlightRes (aCtx)->First()->IsValid()
- ? anAspectMarker->SpriteHighlightRes (aCtx)
+ const Handle(OpenGl_TextureSet)& aSprite = toHilight && anAspectFace->SpriteHighlightRes (aCtx)->First()->IsValid()
+ ? anAspectFace->SpriteHighlightRes (aCtx)
: aSpriteNormRes;
aCtx->BindTextures (aSprite);
- aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
+ aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
}
else
{
- aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
+ aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, Graphic3d_AlphaMode_Opaque, hasVertColor, anAspectFace->ShaderProgramRes (aCtx));
}
break;
}
{
aShadingModel = aCtx->ShaderManager()->ChooseLineShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
aCtx->ShaderManager()->BindLineProgram (NULL,
- anAspectLine->Aspect()->Type(),
+ anAspectFace->Aspect()->LineType(),
aShadingModel,
Graphic3d_AlphaMode_Opaque,
hasVertColor,
- anAspectLine->ShaderProgramRes (aCtx));
+ anAspectFace->ShaderProgramRes (aCtx));
break;
}
default:
{
aCtx->SetTextureMatrix (aCtx->ActiveTextures()->First()->Sampler()->Parameters());
}
+ aCtx->SetSampleAlphaToCoverage (aCtx->ShaderManager()->MaterialState().HasAlphaCutoff());
const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_HIDDENLINE
? myBounds->Colors
: NULL;
+ const OpenGl_Vec4& anInteriorColor = theWorkspace->InteriorColor();
+ aCtx->SetColor4fv (anInteriorColor);
if (!myIsFillType)
{
- const OpenGl_Vec4& aLineColor = myDrawMode == GL_POINTS ? theWorkspace->MarkerColor() : theWorkspace->LineColor();
- aCtx->SetColor4fv (aLineColor);
if (myDrawMode == GL_LINES
|| myDrawMode == GL_LINE_STRIP)
{
- aCtx->SetTypeOfLine (anAspectLine->Aspect()->Type());
- aCtx->SetLineWidth (anAspectLine->Aspect()->Width());
+ aCtx->SetTypeOfLine (anAspectFace->Aspect()->LineType());
+ aCtx->SetLineWidth (anAspectFace->Aspect()->LineWidth());
}
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
return;
}
- const OpenGl_Vec4& anInteriorColor = theWorkspace->InteriorColor();
- aCtx->SetColor4fv (anInteriorColor);
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
// draw outline - only closed triangulation with defined vertex normals can be drawn in this way
}
else
{
- const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
- drawEdges (anEdgeColor, theWorkspace);
+ drawEdges (theWorkspace);
}
}
#endif
const Standard_Boolean theHasVertColor) const;
//! Auxiliary procedures
- void drawEdges (const OpenGl_Vec4& theEdgeColour,
- const Handle(OpenGl_Workspace)& theWorkspace) const;
+ void drawEdges (const Handle(OpenGl_Workspace)& theWorkspace) const;
void drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const;
#include <typeinfo>
#include <Graphic3d_TextureParams.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_ClippingIterator.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx>
return;
}
- myContext->SetSampleAlphaToCoverage (false);
if (myMaterialState.AlphaCutoff() < ShortRealLast())
{
glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
return;
}
- myContext->SetSampleAlphaToCoverage (myMaterialState.HasAlphaCutoff());
theProgram->SetUniform (myContext,
theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
myMaterialState.AlphaCutoff());
// purpose :
// =======================================================================
void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
- const Handle(Graphic3d_AspectFillArea3d)& theAspect) const
+ const Handle(Graphic3d_Aspects)& theAspect) const
{
if (theProgram.IsNull()
|| !theProgram->IsValid())
#include <OpenGl_SetOfShaderPrograms.hxx>
#include <OpenGl_ShaderStates.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectText.hxx>
-#include <OpenGl_AspectMarker.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_MaterialState.hxx>
#include <OpenGl_Texture.hxx>
//! Setup interior style line edges variables.
Standard_EXPORT void PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
- const Handle(Graphic3d_AspectFillArea3d)& theAspect) const;
+ const Handle(Graphic3d_Aspects)& theAspect) const;
public:
const Graphic3d_Vec3d aSize = myBndBox.Size();
aCtx->ActiveProgram()->SetUniform (aCtx, "occBBoxCenter", Graphic3d_Vec3 ((float )aCenter.x(), (float )aCenter.y(), (float )aCenter.z()));
aCtx->ActiveProgram()->SetUniform (aCtx, "occBBoxSize", Graphic3d_Vec3 ((float )aSize.x(), (float )aSize.y(), (float )aSize.z()));
- aCtx->SetColor4fv (theWorkspace->LineColor());
+ aCtx->SetColor4fv (theWorkspace->InteriorColor());
const Handle(OpenGl_VertexBuffer)& aBoundBoxVertBuffer = aCtx->ShaderManager()->BoundBoxVertBuffer();
aBoundBoxVertBuffer->BindAttribute (aCtx, Graphic3d_TOA_POS);
};
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID, Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, false, Handle(OpenGl_ShaderProgram)());
- aCtx->SetColor4fv (theWorkspace->LineColor());
+ aCtx->SetColor4fv (theWorkspace->InteriorColor());
aCtx->core11fwd->glDisable (GL_LIGHTING);
aCtx->core11->glEnableClientState (GL_VERTEX_ARRAY);
aCtx->core11->glVertexPointer (3, GL_FLOAT, 0, aVerts[0].GetData());
aCtx->ApplyModelViewMatrix();
// remember aspects
- const OpenGl_AspectLine* aPrevAspectLine = theWorkspace->AspectLine();
- const OpenGl_AspectFace* aPrevAspectFace = theWorkspace->AspectFace();
- const OpenGl_AspectMarker* aPrevAspectMarker = theWorkspace->AspectMarker();
- const OpenGl_AspectText* aPrevAspectText = theWorkspace->AspectText();
+ const OpenGl_Aspects* aPrevAspectFace = theWorkspace->Aspects();
// Apply correction for mirror transform
if (myIsMirrored)
aCtx->SetGlNormalizeEnabled (anOldGlNormalize);
// Restore aspects
- theWorkspace->SetAspectLine (aPrevAspectLine);
- theWorkspace->SetAspectFace (aPrevAspectFace);
- theWorkspace->SetAspectMarker (aPrevAspectMarker);
- theWorkspace->SetAspectText (aPrevAspectText);
+ theWorkspace->SetAspects (aPrevAspectFace);
// Apply highlight box
if (!isClipped
#include <Graphic3d_CStructure.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_Group.hxx>
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OpenGl_ShaderManager.hxx>
0.0, 0.0, 0.0, 1.0
};
+ static const TCollection_AsciiString THE_DEFAULT_FONT (Font_NOF_ASCII_MONO);
+
//! Auxiliary tool for setting polygon offset temporarily.
struct BackPolygonOffsetSentry
{
// =======================================================================
void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theText,
- const OpenGl_AspectText& theTextAspect,
+ const OpenGl_Aspects& theTextAspect,
const OpenGl_TextParam& theParams,
const unsigned int theResolution,
Standard_ShortReal& theWidth,
// =======================================================================
void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
- theWorkspace->SetAspectFace (&theWorkspace->FontFaceAspect());
- theWorkspace->ApplyAspectFace();
- const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText();
- const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
+ const OpenGl_Aspects* aTextAspect = theWorkspace->ApplyAspects();
+ const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)());
// Bind custom shader program or generate default version
// purpose :
// =======================================================================
void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const unsigned int theResolution) const
+ const OpenGl_Aspects& theTextAspect,
+ unsigned int theResolution) const
{
- const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
#if !defined(GL_ES_VERSION_2_0)
const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL);
const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
theCtx->SetPolygonMode (aPrevPolygonMode);
theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
#endif
- theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
}
// =======================================================================
// purpose :
// =======================================================================
void OpenGl_Text::setupMatrix (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const OpenGl_Vec3 theDVec) const
+ const OpenGl_Aspects& theTextAspect,
+ const OpenGl_Vec3& theDVec) const
{
OpenGl_Mat4d aModViewMat;
OpenGl_Mat4d aProjectMat;
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, myPoint.x() + theDVec.x(), myPoint.y() + theDVec.y(), 0.f);
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, 1.f, -1.f, 1.f);
- Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.f, 0.f, 1.f);
+ Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.f, 0.f, 1.f);
}
else
{
else
{
Graphic3d_TransformUtils::Translate<GLdouble> (aModViewMat, anObjX, anObjY, anObjZ);
- Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->GetTextAngle(), 0.0, 0.0, 1.0);
+ Graphic3d_TransformUtils::Rotate<GLdouble> (aModViewMat, theTextAspect.Aspect()->TextAngle(), 0.0, 0.0, 1.0);
}
- if (!theTextAspect.Aspect()->GetTextZoomable())
+ if (!theTextAspect.Aspect()->IsTextZoomable())
{
Graphic3d_TransformUtils::Scale<GLdouble> (aModViewMat, myScaleHeight, myScaleHeight, myScaleHeight);
}
// purpose :
// =======================================================================
void OpenGl_Text::drawText (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect) const
+ const OpenGl_Aspects& theTextAspect) const
{
(void )theTextAspect;
if (myVertsVbo.Length() != myTextures.Length()
// function : FontKey
// purpose :
// =======================================================================
-TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_AspectText& theAspect,
- const Standard_Integer theHeight,
- const unsigned int theResolution)
+TCollection_AsciiString OpenGl_Text::FontKey (const OpenGl_Aspects& theAspect,
+ Standard_Integer theHeight,
+ unsigned int theResolution)
{
- const Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
- ? theAspect.Aspect()->GetTextFontAspect()
+ const Font_FontAspect anAspect = theAspect.Aspect()->TextFontAspect() != Font_FA_Undefined
+ ? theAspect.Aspect()->TextFontAspect()
: Font_FA_Regular;
- return theAspect.Aspect()->Font()
+ const TCollection_AsciiString& aFont = !theAspect.Aspect()->TextFont().IsNull() ? theAspect.Aspect()->TextFont()->String() : THE_DEFAULT_FONT;
+ return aFont
+ TCollection_AsciiString(":") + Standard_Integer(anAspect)
+ TCollection_AsciiString(":") + Standard_Integer(theResolution)
+ TCollection_AsciiString(":") + theHeight;
// purpose :
// =======================================================================
Handle(OpenGl_Font) OpenGl_Text::FindFont (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theAspect,
- const Standard_Integer theHeight,
- const unsigned int theResolution,
- const TCollection_AsciiString theKey)
+ const OpenGl_Aspects& theAspect,
+ Standard_Integer theHeight,
+ unsigned int theResolution,
+ const TCollection_AsciiString& theKey)
{
Handle(OpenGl_Font) aFont;
if (theHeight < 2)
if (!theCtx->GetResource (theKey, aFont))
{
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
- const TCollection_AsciiString& aFontName = theAspect.Aspect()->Font();
- Font_FontAspect anAspect = theAspect.Aspect()->GetTextFontAspect() != Font_FA_Undefined
- ? theAspect.Aspect()->GetTextFontAspect()
+ const TCollection_AsciiString& aFontName = !theAspect.Aspect()->TextFont().IsNull()
+ ? theAspect.Aspect()->TextFont()->String()
+ : THE_DEFAULT_FONT;
+ Font_FontAspect anAspect = theAspect.Aspect()->TextFontAspect() != Font_FA_Undefined
+ ? theAspect.Aspect()->TextFontAspect()
: Font_FA_Regular;
Handle(Font_FTFont) aFontFt;
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (aFontName, anAspect))
{
TCollection_ExtendedString aMsg;
aMsg += "Font '";
- aMsg += theAspect.Aspect()->Font();
+ aMsg += aFontName;
aMsg += "' - initialization of GL resources has failed!";
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
aFontFt.Nullify();
{
TCollection_ExtendedString aMsg;
aMsg += "Font '";
- aMsg += theAspect.Aspect()->Font();
+ aMsg += aFontName;
aMsg += "' is broken or has incompatible format! File path: ";
aMsg += aRequestedFont->FontPathAny (anAspect);
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
{
TCollection_ExtendedString aMsg;
aMsg += "Font '";
- aMsg += theAspect.Aspect()->Font();
+ aMsg += aFontName;
aMsg += "' is not found in the system!";
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aMsg);
aFont = new OpenGl_Font (aFontFt, theKey);
// purpose :
// =======================================================================
void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const OpenGl_Vec4& theColorSubs) const
+ const OpenGl_Aspects& theTextAspect,
+ const OpenGl_Vec4& theColorSubs) const
{
Handle(OpenGl_ShaderProgram) aPrevProgram = theCtx->ActiveProgram();
if (myBndVertsVbo.IsNull())
// purpose :
// =======================================================================
void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const OpenGl_Vec4& theColorText,
- const OpenGl_Vec4& theColorSubs,
- const unsigned int theResolution) const
+ const OpenGl_Aspects& theTextAspect,
+ const OpenGl_Vec4& theColorText,
+ const OpenGl_Vec4& theColorSubs,
+ unsigned int theResolution) const
{
if (myString.IsEmpty())
{
myWinX, myWinY, myWinZ);
// compute scale factor for constant text height
- if (theTextAspect.Aspect()->GetTextZoomable())
+ if (theTextAspect.Aspect()->IsTextZoomable())
{
myExportHeight = aPointSize;
}
// setup depth test
const bool hasDepthTest = !myIs2d
- && theTextAspect.Aspect()->Style() != Aspect_TOST_ANNOTATION;
+ && theTextAspect.Aspect()->TextStyle() != Aspect_TOST_ANNOTATION;
if (!hasDepthTest)
{
glDisable (GL_DEPTH_TEST);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ // alpha to coverage makes text too thin
+ theCtx->SetSampleAlphaToCoverage (false);
+
// extra drawings
- switch (theTextAspect.Aspect()->DisplayType())
+ switch (theTextAspect.Aspect()->TextDisplayType())
{
case Aspect_TODT_BLEND:
{
}
#endif
- if (theTextAspect.Aspect()->DisplayType() == Aspect_TODT_DIMENSION)
+ if (theTextAspect.Aspect()->TextDisplayType() == Aspect_TODT_DIMENSION)
{
glDisable (GL_BLEND);
if (!myIs2d)
#include <OpenGl_Element.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_TextParam.hxx>
#include <OpenGl_TextBuilder.hxx>
Standard_EXPORT OpenGl_Text();
//! Create key for shared resource
- Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_AspectText& theAspect,
- const Standard_Integer theHeight,
- const unsigned int theResolution);
+ Standard_EXPORT static TCollection_AsciiString FontKey (const OpenGl_Aspects& theAspect,
+ Standard_Integer theHeight,
+ unsigned int theResolution);
//! Find shared resource for specified font or initialize new one
Standard_EXPORT static Handle(OpenGl_Font) FindFont (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theAspect,
- const Standard_Integer theHeight,
- const unsigned int theResolution,
- const TCollection_AsciiString theKey);
+ const OpenGl_Aspects& theAspect,
+ Standard_Integer theHeight,
+ unsigned int theResolution,
+ const TCollection_AsciiString& theKey);
//! Compute text width
Standard_EXPORT static void StringSize (const Handle(OpenGl_Context)& theCtx,
const NCollection_String& theText,
- const OpenGl_AspectText& theTextAspect,
+ const OpenGl_Aspects& theTextAspect,
const OpenGl_TextParam& theParams,
const unsigned int theResolution,
Standard_ShortReal& theWidth,
//! Perform rendering
Standard_EXPORT void Render (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
+ const OpenGl_Aspects& theTextAspect,
+ unsigned int theResolution = Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION) const;
protected:
//! Setup matrix.
void setupMatrix (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const OpenGl_Vec3 theDVec) const;
+ const OpenGl_Aspects& theTextAspect,
+ const OpenGl_Vec3& theDVec) const;
//! Draw arrays of vertices.
void drawText (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect) const;
+ const OpenGl_Aspects& theTextAspect) const;
//! Draw rectangle from bounding text box.
void drawRect (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const OpenGl_Vec4& theColorSubs) const;
+ const OpenGl_Aspects& theTextAspect,
+ const OpenGl_Vec4& theColorSubs) const;
//! Main rendering code
void render (const Handle(OpenGl_Context)& theCtx,
- const OpenGl_AspectText& theTextAspect,
- const OpenGl_Vec4& theColorText,
- const OpenGl_Vec4& theColorSubs,
- const unsigned int theResolution) const;
+ const OpenGl_Aspects& theTextAspect,
+ const OpenGl_Vec4& theColorText,
+ const OpenGl_Vec4& theColorSubs,
+ unsigned int theResolution) const;
protected:
myTransientDrawToFront (Standard_True),
myBackBufferRestored (Standard_False),
myIsImmediateDrawn (Standard_False),
- myTextureParams (new OpenGl_AspectFace()),
+ myTextureParams (new OpenGl_Aspects()),
myBgGradientArray (new OpenGl_BackgroundArray (Graphic3d_TOB_GRADIENT)),
myBgTextureArray (new OpenGl_BackgroundArray (Graphic3d_TOB_TEXTURE)),
// ray-tracing fields initialization
#include <Graphic3d_WorldViewProjState.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
-#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_BackgroundArray.hxx>
#include <OpenGl_BVHTreeSelector.hxx>
#include <OpenGl_Context.hxx>
protected: //! @name Background parameters
- OpenGl_AspectFace* myTextureParams; //!< Stores texture and its parameters for textured background
+ OpenGl_Aspects* myTextureParams; //!< Stores texture and its parameters for textured background
OpenGl_BackgroundArray* myBgGradientArray; //!< Primitive array for gradient background
OpenGl_BackgroundArray* myBgTextureArray; //!< Primitive array for texture background
const Handle(OpenGl_Context)& theGlContext);
//! Creates ray-tracing material properties.
- OpenGl_RaytraceMaterial convertMaterial (const OpenGl_AspectFace* theAspect,
+ OpenGl_RaytraceMaterial convertMaterial (const OpenGl_Aspects* theAspect,
const Handle(OpenGl_Context)& theGlContext);
//! Adds OpenGL primitive array to ray-traced scene geometry.
// function : convertMaterial
// purpose : Creates ray-tracing material properties
// =======================================================================
-OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_AspectFace* theAspect,
+OpenGl_RaytraceMaterial OpenGl_View::convertMaterial (const OpenGl_Aspects* theAspect,
const Handle(OpenGl_Context)& theGlContext)
{
OpenGl_RaytraceMaterial theMaterial;
{
// Get group material
OpenGl_RaytraceMaterial aGroupMaterial;
- if (aGroupIter.Value()->AspectFace() != NULL)
+ if (aGroupIter.Value()->GlAspects() != NULL)
{
- aGroupMaterial = convertMaterial (
- aGroupIter.Value()->AspectFace(), theGlContext);
+ aGroupMaterial = convertMaterial (aGroupIter.Value()->GlAspects(), theGlContext);
}
Standard_Integer aMatID = static_cast<Standard_Integer> (myRaytraceGeometry.Materials.size());
// Use group material if available, otherwise use structure material
- myRaytraceGeometry.Materials.push_back (
- aGroupIter.Value()->AspectFace() != NULL ? aGroupMaterial : theStructMat);
+ myRaytraceGeometry.Materials.push_back (aGroupIter.Value()->GlAspects() != NULL ? aGroupMaterial : theStructMat);
// Add OpenGL elements from group (extract primitives arrays and aspects)
for (const OpenGl_ElementNode* aNode = aGroupIter.Value()->FirstNode(); aNode != NULL; aNode = aNode->next)
{
- OpenGl_AspectFace* anAspect = dynamic_cast<OpenGl_AspectFace*> (aNode->elem);
+ OpenGl_Aspects* anAspect = dynamic_cast<OpenGl_Aspects*> (aNode->elem);
if (anAspect != NULL)
{
#include <NCollection_Mat4.hxx>
-#include <OpenGl_AspectLine.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_FrameStats.hxx>
#include <OpenGl_Matrix.hxx>
{
aCtx->core11fwd->glDisable (GL_BLEND);
- const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace (myTextureParams);
+ const OpenGl_Aspects* anOldAspectFace = theWorkspace->SetAspects (myTextureParams);
myBgTextureArray->Render (theWorkspace);
- theWorkspace->SetAspectFace (anOldAspectFace);
+ theWorkspace->SetAspects (anOldAspectFace);
}
if (wasUsedZBuffer)
if (aVerts->IsValid()
&& aManager->BindFboBlitProgram())
{
+ aCtx->SetSampleAlphaToCoverage (false);
theReadFbo->ColorTexture()->Bind (aCtx, Graphic3d_TextureUnit_0);
if (theReadFbo->ColorTexture()->Sampler()->Parameters()->Filter() != aFilter)
{
#include <OpenGl_Workspace.hxx>
#include <OpenGl_ArbFBO.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_FrameBuffer.hxx>
myNbSkippedTranspElems (0),
myRenderFilter (OpenGl_RenderFilter_Empty),
//
- myAspectLineSet (&myDefaultAspectLine),
- myAspectFaceSet (&myDefaultAspectFace),
- myAspectMarkerSet (&myDefaultAspectMarker),
- myAspectTextSet (&myDefaultAspectText),
+ myAspectsSet (&myDefaultAspects),
//
ViewMatrix_applied (&myDefaultMatrix),
StructureMatrix_applied (&myDefaultMatrix),
#endif
}
- myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend, 0.285f);
- myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
-
myNoneCulling .Aspect()->SetSuppressBackFaces (false);
myNoneCulling .Aspect()->SetDrawEdges (false);
myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
{
myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
}
-
-#if !defined(GL_ES_VERSION_2_0)
- // font GLSL program has embedded discard, while FFP needs alpha test
- myFontFaceAspect.Aspect()->SetAlphaMode ((!myGlContext->caps->ffpEnable && myGlContext->core11 != NULL)
- ? Graphic3d_AlphaMode_Blend
- : Graphic3d_AlphaMode_Mask,
- 0.285f);
-#endif
return Standard_True;
}
myHighlightStyle.Nullify();
myToAllowFaceCulling = false;
- myAspectLineSet = &myDefaultAspectLine;
- myAspectFaceSet = &myDefaultAspectFace;
- myAspectFaceApplied.Nullify();
- myAspectMarkerSet = &myDefaultAspectMarker;
- myAspectMarkerApplied.Nullify();
- myAspectTextSet = &myDefaultAspectText;
+ myAspectsSet = &myDefaultAspects;
+ myAspectsApplied.Nullify();
myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
- ApplyAspectLine();
- ApplyAspectFace();
- ApplyAspectMarker();
- ApplyAspectText();
-
- myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type());
- myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
+ ApplyAspects();
+ myGlContext->SetTypeOfLine (myDefaultAspects.Aspect()->LineType());
+ myGlContext->SetLineWidth (myDefaultAspects.Aspect()->LineWidth());
}
// =======================================================================
// =======================================================================
Graphic3d_PolygonOffset OpenGl_Workspace::SetDefaultPolygonOffset (const Graphic3d_PolygonOffset& theOffset)
{
- Graphic3d_PolygonOffset aPrev = myDefaultAspectFace.Aspect()->PolygonOffset();
- myDefaultAspectFace.Aspect()->SetPolygonOffset (theOffset);
- if (myAspectFaceApplied == myDefaultAspectFace.Aspect()
- || myAspectFaceApplied.IsNull()
- || (myAspectFaceApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
+ Graphic3d_PolygonOffset aPrev = myDefaultAspects.Aspect()->PolygonOffset();
+ myDefaultAspects.Aspect()->SetPolygonOffset (theOffset);
+ if (myAspectsApplied == myDefaultAspects.Aspect()
+ || myAspectsApplied.IsNull()
+ || (myAspectsApplied->PolygonOffset().Mode & Aspect_POM_None) == Aspect_POM_None)
{
myGlContext->SetPolygonOffset (theOffset);
}
}
// =======================================================================
-// function : SetAspectLine
-// purpose :
-// =======================================================================
-const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
-{
- const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
- myAspectLineSet = theAspect;
- return aPrevAspectLine;
-}
-
-// =======================================================================
-// function : SetAspectFace
-// purpose :
-// =======================================================================
-const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
-{
- const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
- myAspectFaceSet = theAspect;
- return aPrevAspectFace;
-}
-
-// =======================================================================
-// function : SetAspectMarker
+// function : SetAspects
// purpose :
// =======================================================================
-const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
+const OpenGl_Aspects* OpenGl_Workspace::SetAspects (const OpenGl_Aspects* theAspect)
{
- const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
- myAspectMarkerSet = theAspect;
- return aPrevAspectMarker;
+ const OpenGl_Aspects* aPrevAspects = myAspectsSet;
+ myAspectsSet = theAspect;
+ return aPrevAspects;
}
// =======================================================================
-// function : SetAspectText
+// function : ApplyAspects
// purpose :
// =======================================================================
-const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
-{
- const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
- myAspectTextSet = theAspect;
- return aPrevAspectText;
-}
-
-// =======================================================================
-// function : ApplyAspectFace
-// purpose :
-// =======================================================================
-const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
+const OpenGl_Aspects* OpenGl_Workspace::ApplyAspects()
{
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
{
bool toSuppressBackFaces = myToAllowFaceCulling
- && myAspectFaceSet->Aspect()->ToSuppressBackFaces();
+ && myAspectsSet->Aspect()->ToSuppressBackFaces();
if (toSuppressBackFaces)
{
- if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
- || myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
- || myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
- || (myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
- && myAspectFaceSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
+ if (myAspectsSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH
+ || myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
+ || myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
+ || (myAspectsSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
+ && myAspectsSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
{
// disable culling in case of translucent shading aspect
toSuppressBackFaces = false;
myGlContext->SetCullBackFaces (toSuppressBackFaces);
}
- if (myAspectFaceSet->Aspect() == myAspectFaceApplied
+ if (myAspectsSet->Aspect() == myAspectsApplied
&& myHighlightStyle == myAspectFaceAppliedWithHL)
{
- return myAspectFaceSet;
+ return myAspectsSet;
}
myAspectFaceAppliedWithHL = myHighlightStyle;
// Aspect_POM_None means: do not change current settings
- if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
+ if ((myAspectsSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
{
- myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
+ myGlContext->SetPolygonOffset (myAspectsSet->Aspect()->PolygonOffset());
}
- const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
- if (myAspectFaceApplied.IsNull()
- || myAspectFaceApplied->InteriorStyle() != anIntstyle)
+ const Aspect_InteriorStyle anIntstyle = myAspectsSet->Aspect()->InteriorStyle();
+ if (myAspectsApplied.IsNull()
+ || myAspectsApplied->InteriorStyle() != anIntstyle)
{
#if !defined(GL_ES_VERSION_2_0)
myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL);
#if !defined(GL_ES_VERSION_2_0)
if (anIntstyle == Aspect_IS_HATCH)
{
- myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
+ myGlContext->SetPolygonHatchStyle (myAspectsSet->Aspect()->HatchStyle());
}
#endif
if (anIntstyle == Aspect_IS_HIDDENLINE)
{
// copy all values including line edge aspect
- *myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
- myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
+ *myAspectFaceHl.Aspect() = *myAspectsSet->Aspect();
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
myAspectFaceHl.Aspect()->SetDistinguish (false);
myAspectFaceHl.SetNoLighting();
- myAspectFaceSet = &myAspectFaceHl;
+ myAspectsSet = &myAspectFaceHl;
}
else
{
- myGlContext->SetShadingMaterial (myAspectFaceSet, myHighlightStyle);
+ myGlContext->SetShadingMaterial (myAspectsSet, myHighlightStyle);
}
- if (myAspectFaceSet->Aspect()->ToMapTexture())
+ if (myAspectsSet->Aspect()->ToMapTexture())
{
- myGlContext->BindTextures (myAspectFaceSet->TextureSet (myGlContext));
+ myGlContext->BindTextures (myAspectsSet->TextureSet (myGlContext));
}
else
{
myGlContext->BindTextures (myEnvironmentTexture);
}
- myAspectFaceApplied = myAspectFaceSet->Aspect();
- return myAspectFaceSet;
-}
-
-// =======================================================================
-// function : ApplyAspectMarker
-// purpose :
-// =======================================================================
-const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
-{
- if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
- {
- if (myAspectMarkerApplied.IsNull()
- || (myAspectMarkerSet->Aspect()->Scale() != myAspectMarkerApplied->Scale()))
- {
- #if !defined(GL_ES_VERSION_2_0)
- glPointSize (myAspectMarkerSet->Aspect()->Scale());
- #endif
- }
- myAspectMarkerApplied = myAspectMarkerSet->Aspect();
- }
- return myAspectMarkerSet;
+ myAspectsApplied = myAspectsSet->Aspect();
+ return myAspectsSet;
}
// =======================================================================
return true;
}
- if (OpenGl_Context::CheckIsTransparent (myAspectFaceSet, myHighlightStyle))
+ if (OpenGl_Context::CheckIsTransparent (myAspectsSet, myHighlightStyle))
{
++myNbSkippedTranspElems;
return false;
{
if (!theElement->IsFillDrawMode())
{
- if (dynamic_cast<const OpenGl_AspectFace*> (theElement) == NULL)
+ if (dynamic_cast<const OpenGl_Aspects*> (theElement) == NULL)
{
return false;
}
}
- else if (!OpenGl_Context::CheckIsTransparent (myAspectFaceSet, myHighlightStyle))
+ else if (!OpenGl_Context::CheckIsTransparent (myAspectsSet, myHighlightStyle))
{
return false;
}
#include <Graphic3d_BufferType.hxx>
-#include <OpenGl_AspectFace.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_CappingAlgo.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Material.hxx>
//! Set highlight style.
void SetHighlightStyle (const Handle(Graphic3d_PresentationAttributes)& theStyle) { myHighlightStyle = theStyle; }
- //! Return line color taking into account highlight flag.
- const OpenGl_Vec4& LineColor() const
- {
- return !myHighlightStyle.IsNull()
- ? myHighlightStyle->ColorRGBA()
- : myAspectLineSet->Aspect()->ColorRGBA();
- }
-
//! Return edge color taking into account highlight flag.
const OpenGl_Vec4& EdgeColor() const
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
- : myAspectFaceSet->AspectEdge()->Aspect()->ColorRGBA();
- }
-
- //! Return marker color taking into account highlight flag.
- const OpenGl_Vec4& MarkerColor() const
- {
- return !myHighlightStyle.IsNull()
- ? myHighlightStyle->ColorRGBA()
- : myAspectMarkerSet->Aspect()->ColorRGBA();
+ : myAspectsSet->Aspect()->EdgeColorRGBA();
}
//! Return Interior color taking into account highlight flag.
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
- : myAspectFaceSet->Aspect()->InteriorColorRGBA();
+ : myAspectsSet->Aspect()->InteriorColorRGBA();
}
//! Return text color taking into account highlight flag.
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
- : myAspectTextSet->Aspect()->ColorRGBA();
+ : myAspectsSet->Aspect()->ColorRGBA();
}
//! Return text Subtitle color taking into account highlight flag.
{
return !myHighlightStyle.IsNull()
? myHighlightStyle->ColorRGBA()
- : myAspectTextSet->Aspect()->ColorSubTitleRGBA();
+ : myAspectsSet->Aspect()->ColorSubTitleRGBA();
}
- //! Currently set line aspect (can differ from applied).
- const OpenGl_AspectLine* AspectLine() const { return myAspectLineSet; }
-
- //! Currently set face aspect (can differ from applied).
- const OpenGl_AspectFace* AspectFace() const { return myAspectFaceSet; }
+ //! Currently set aspects (can differ from applied).
+ const OpenGl_Aspects* Aspects() const { return myAspectsSet; }
- //! Currently set marker aspect (can differ from applied).
- const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
+ //! Assign new aspects (will be applied within ApplyAspects()).
+ Standard_EXPORT const OpenGl_Aspects* SetAspects (const OpenGl_Aspects* theAspect);
- //! Currently set text aspect (can differ from applied).
- const OpenGl_AspectText* AspectText() const { return myAspectTextSet; }
-
- //! Assign new line aspect (will be applied within ApplyAspectLine()).
- Standard_EXPORT const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect);
-
- //! Assign new face aspect (will be applied within ApplyAspectFace()).
- Standard_EXPORT const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect);
-
- //! Assign new marker aspect (will be applied within ApplyAspectMarker()).
- Standard_EXPORT const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect);
-
- //! Assign new text aspect (will be applied within ApplyAspectText()).
- Standard_EXPORT const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect);
-
- //! Apply line aspect.
- //! @return aspect set by SetAspectLine()
- const OpenGl_AspectLine* ApplyAspectLine() { return myAspectLineSet; }
-
- //! Apply face aspect.
- //! @return aspect set by SetAspectFace()
- Standard_EXPORT const OpenGl_AspectFace* ApplyAspectFace();
-
- //! Apply marker aspect.
- //! @return aspect set by SetAspectMarker()
- Standard_EXPORT const OpenGl_AspectMarker* ApplyAspectMarker();
-
- //! Apply text aspect.
- //! @return aspect set by SetAspectText()
- const OpenGl_AspectText* ApplyAspectText() { return myAspectTextSet; }
+ //! Apply aspects.
+ //! @return aspect set by SetAspects()
+ Standard_EXPORT const OpenGl_Aspects* ApplyAspects();
//! Clear the applied aspect state to default values.
void ResetAppliedAspect();
//! @return applied model structure matrix.
inline const OpenGl_Matrix* ModelMatrix() const { return StructureMatrix_applied; }
- //! Returns face aspect for textured font rendering.
- const OpenGl_AspectFace& FontFaceAspect() const { return myFontFaceAspect; }
-
//! Returns face aspect for none culling mode.
- const OpenGl_AspectFace& NoneCulling() const { return myNoneCulling; }
+ const OpenGl_Aspects& NoneCulling() const { return myNoneCulling; }
//! Returns face aspect for front face culling mode.
- const OpenGl_AspectFace& FrontCulling() const { return myFrontCulling; }
+ const OpenGl_Aspects& FrontCulling() const { return myFrontCulling; }
//! Sets a new environment texture.
void SetEnvironmentTexture (const Handle(OpenGl_TextureSet)& theTexture) { myEnvironmentTexture = theTexture; }
protected: //! @name protected fields
- OpenGl_View* myView;
- Handle(OpenGl_Window) myWindow;
- Handle(OpenGl_Context) myGlContext;
- Standard_Boolean myUseZBuffer;
- Standard_Boolean myUseDepthWrite;
- OpenGl_AspectFace myNoneCulling;
- OpenGl_AspectFace myFrontCulling;
- OpenGl_AspectFace myFontFaceAspect;
+ OpenGl_View* myView;
+ Handle(OpenGl_Window) myWindow;
+ Handle(OpenGl_Context) myGlContext;
+ Standard_Boolean myUseZBuffer;
+ Standard_Boolean myUseDepthWrite;
+ OpenGl_Aspects myNoneCulling;
+ OpenGl_Aspects myFrontCulling;
protected: //! @name fields related to status
Standard_Integer myNbSkippedTranspElems; //!< counter of skipped transparent elements for OpenGl_LayerList two rendering passes method
Standard_Integer myRenderFilter; //!< active filter for skipping rendering of elements by some criteria (multiple render passes)
- OpenGl_AspectLine myDefaultAspectLine;
- OpenGl_AspectFace myDefaultAspectFace;
- OpenGl_AspectMarker myDefaultAspectMarker;
- OpenGl_AspectText myDefaultAspectText;
-
- const OpenGl_AspectLine* myAspectLineSet;
- const OpenGl_AspectFace* myAspectFaceSet;
- Handle(Graphic3d_AspectFillArea3d) myAspectFaceApplied;
- const OpenGl_AspectMarker* myAspectMarkerSet;
- Handle(Graphic3d_AspectMarker3d) myAspectMarkerApplied;
- const OpenGl_AspectText* myAspectTextSet;
+ OpenGl_Aspects myDefaultAspects;
+ const OpenGl_Aspects* myAspectsSet;
+ Handle(Graphic3d_Aspects) myAspectsApplied;
+
Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL;
const OpenGl_Matrix* ViewMatrix_applied;
OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
- OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
+ OpenGl_Aspects myAspectFaceHl; //!< Hiddenline aspect
Handle(OpenGl_TextureSet) myEnvironmentTexture;
// =======================================================================
Prs3d_TextAspect::Prs3d_TextAspect()
: myTextAspect (new Graphic3d_AspectText3d (Quantity_Color (Quantity_NOC_YELLOW), Font_NOF_ASCII_TRIPLEX, 1.0, 0.0)),
- myAngle (0.0),
myHeight(16.0),
myHorizontalJustification (Graphic3d_HTA_LEFT),
myVerticalJustification (Graphic3d_VTA_BOTTOM),
// =======================================================================
Prs3d_TextAspect::Prs3d_TextAspect (const Handle(Graphic3d_AspectText3d)& theAspect)
: myTextAspect (theAspect),
- myAngle (0.0),
myHeight(16.0),
myHorizontalJustification (Graphic3d_HTA_LEFT),
myVerticalJustification (Graphic3d_VTA_BOTTOM),
//! Sets the font used in text display.
void SetFont (const Standard_CString theFont) { myTextAspect->SetFont (theFont); }
-
- //! Returns the height-width ratio, also known as the expansion factor.
- void SetHeightWidthRatio (const Standard_Real theRatio) { myTextAspect->SetExpansionFactor (theRatio); }
- //! Sets the length of the box which text will occupy.
- void SetSpace (const Standard_Real theSpace) { myTextAspect->SetSpace (theSpace); }
-
//! Sets the height of the text.
void SetHeight (const Standard_Real theHeight) { myHeight = theHeight; }
//! Sets the angle
- void SetAngle (const Standard_Real theAngle) { myAngle = theAngle; }
+ void SetAngle (const Standard_Real theAngle) { myTextAspect->SetTextAngle (theAngle); }
//! Returns the height of the text box.
Standard_Real Height() const { return myHeight; }
//! Returns the angle
- Standard_Real Angle() const { return myAngle; }
+ Standard_Real Angle() const { return myTextAspect->GetTextAngle(); }
//! Sets horizontal alignment of text.
void SetHorizontalJustification (const Graphic3d_HorizontalTextAlignment theJustification) { myHorizontalJustification = theJustification; }
protected:
Handle(Graphic3d_AspectText3d) myTextAspect;
- Standard_Real myAngle;
Standard_Real myHeight;
Graphic3d_HorizontalTextAlignment myHorizontalJustification;
Graphic3d_VerticalTextAlignment myVerticalJustification;
}
}
+//=======================================================================
+//function : recomputeComputed
+//purpose :
+//=======================================================================
+void PrsMgr_PresentableObject::recomputeComputed() const
+{
+ for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
+ {
+ const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
+ if (!aPrs3d.IsNull()
+ && !aPrs3d->Presentation().IsNull())
+ {
+ aPrs3d->Presentation()->ReCompute();
+ }
+ }
+}
+
//=======================================================================
//function : SetTransformPersistence
//purpose :
//! Sets local transformation to theTransformation.
Standard_EXPORT virtual void setLocalTransformation (const Handle(Geom_Transformation)& theTransformation);
+ //! Recompute computed (HLR) presentations (when view is in computed mode).
+ Standard_EXPORT void recomputeComputed() const;
+
private:
//! Return the identity transformation.
{
if (Handle(Graphic3d_ArrayOfSegments) aBndSegments = fillFaceBoundaries (theShape, theDrawer->FaceBoundaryUpperContinuity()))
{
- Handle(Graphic3d_Group) aPrsGrp = Prs3d_Root::CurrentGroup (thePrs);
+ Handle(Graphic3d_Group) aPrsGrp = thePrs->NewGroup();
aPrsGrp->SetGroupPrimitivesAspect (theDrawer->FaceBoundaryAspect()->Aspect());
aPrsGrp->AddPrimitiveArray (aBndSegments);
}
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
+#include <TopExp.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <Standard_Mutex.hxx>
return;
}
- Prs3d_ShapeTool aTool (theShape, theDrawer->VertexDrawMode() == Prs3d_VDM_All);
-
- // Explore shape elements.
- TopTools_ListOfShape aLFree, aLUnFree, aLWire;
- for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
- {
- const TopoDS_Edge& anEdge = aTool.GetCurve();
- switch (aTool.Neighbours())
- {
- case 0: aLWire.Append (anEdge); break;
- case 1: aLFree.Append (anEdge); break;
- default: aLUnFree.Append (anEdge); break;
- }
- }
-
- Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
-
- // Draw shape elements
+ // draw triangulation-only edges
+ if (Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True))
{
- Handle(Graphic3d_ArrayOfPrimitives) aTriFreeEdges = AddEdgesOnTriangulation (theShape, Standard_True);
- if (!aTriFreeEdges.IsNull())
- {
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
- aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
- aGroup->AddPrimitiveArray (aTriFreeEdges);
- }
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aTriFreeEdges);
}
Prs3d_NListOfSequenceOfPnt aCommonPolylines;
const Handle(Prs3d_LineAspect)& aWireAspect = theDrawer->WireAspect();
+ const Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
// Draw isolines
{
const Handle(Prs3d_LineAspect)& anIsoAspectV = theDrawer->VIsoAspect();
if (anIsoAspectV->Aspect()->IsEqual (*anIsoAspectU->Aspect()))
{
- aVPolylinesPtr = aUPolylinesPtr;
+ aVPolylinesPtr = aUPolylinesPtr; // put both U and V isolines into single group
}
if (anIsoAspectU->Aspect()->IsEqual (*aWireAspect->Aspect()))
{
- aUPolylinesPtr = &aCommonPolylines;
+ aUPolylinesPtr = &aCommonPolylines; // put U isolines into single group with common edges
}
if (anIsoAspectV->Aspect()->IsEqual (*aWireAspect->Aspect()))
{
- aVPolylinesPtr = &aCommonPolylines;
+ aVPolylinesPtr = &aCommonPolylines; // put V isolines into single group with common edges
}
bool isParallelIso = false;
Prs3d::AddPrimitivesGroup (thePresentation, anIsoAspectV, aVPolylines);
}
- if (!aLWire.IsEmpty() && theDrawer->WireDraw())
{
- addEdges (aLWire, theDrawer, aShapeDeflection, aCommonPolylines);
- }
-
- if (!aLUnFree.IsEmpty() && theDrawer->UnFreeBoundaryDraw())
- {
- const Handle(Prs3d_LineAspect)& aLineAspect = theDrawer->UnFreeBoundaryAspect();
- if (!aLineAspect->Aspect()->IsEqual (*aWireAspect->Aspect()))
+ Prs3d_NListOfSequenceOfPnt anUnfree, aFree;
+ Prs3d_NListOfSequenceOfPnt* anUnfreePtr = &anUnfree;
+ Prs3d_NListOfSequenceOfPnt* aFreePtr = &aFree;
+ if (!theDrawer->UnFreeBoundaryDraw())
{
- Prs3d_NListOfSequenceOfPnt aPolylines;
- addEdges (aLUnFree, theDrawer, aShapeDeflection, aPolylines);
- Prs3d::AddPrimitivesGroup (thePresentation, aLineAspect, aPolylines);
+ anUnfreePtr = NULL;
}
- else
+ else if (theDrawer->UnFreeBoundaryAspect()->Aspect()->IsEqual (*aWireAspect->Aspect()))
{
- addEdges (aLUnFree, theDrawer, aShapeDeflection, aCommonPolylines);
+ anUnfreePtr = &aCommonPolylines; // put unfree edges into single group with common edges
}
- }
- if (!aLFree.IsEmpty() && theDrawer->FreeBoundaryDraw())
- {
- const Handle(Prs3d_LineAspect)& aLineAspect = theDrawer->FreeBoundaryAspect();
- if (!aLineAspect->Aspect()->IsEqual (*aWireAspect->Aspect()))
+ if (!theDrawer->FreeBoundaryDraw())
{
- Prs3d_NListOfSequenceOfPnt aPolylines;
- addEdges (aLFree, theDrawer, aShapeDeflection, aPolylines);
- Prs3d::AddPrimitivesGroup (thePresentation, aLineAspect, aPolylines);
+ aFreePtr = NULL;
}
- else
+ else if (theDrawer->FreeBoundaryAspect()->Aspect()->IsEqual (*aWireAspect->Aspect()))
{
- addEdges (aLFree, theDrawer, aShapeDeflection, aCommonPolylines);
+ aFreePtr = &aCommonPolylines; // put free edges into single group with common edges
}
+
+ addEdges (theShape,
+ theDrawer,
+ aShapeDeflection,
+ theDrawer->WireDraw() ? &aCommonPolylines : NULL,
+ aFreePtr,
+ anUnfreePtr);
+ Prs3d::AddPrimitivesGroup (thePresentation, theDrawer->UnFreeBoundaryAspect(), anUnfree);
+ Prs3d::AddPrimitivesGroup (thePresentation, theDrawer->FreeBoundaryAspect(), aFree);
}
Prs3d::AddPrimitivesGroup (thePresentation, theDrawer->WireAspect(), aCommonPolylines);
+ if (Handle(Graphic3d_ArrayOfPoints) aVertexArray = AddVertexes (theShape, theDrawer->VertexDrawMode()))
{
- TColgp_SequenceOfPnt aShapeVertices;
- for (aTool.InitVertex(); aTool.MoreVertex(); aTool.NextVertex())
- {
- aShapeVertices.Append (BRep_Tool::Pnt (aTool.GetVertex()));
- }
- if (!aShapeVertices.IsEmpty())
+ Handle(Graphic3d_Group) aGroup = thePresentation->NewGroup();
+ aGroup->SetPrimitivesAspect (theDrawer->PointAspect()->Aspect());
+ aGroup->AddPrimitiveArray (aVertexArray);
+ }
+}
+
+// =========================================================================
+// function : AddAllEdges
+// purpose :
+// =========================================================================
+Handle(Graphic3d_ArrayOfPrimitives) StdPrs_WFShape::AddAllEdges (const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer)
+{
+ const Standard_Real aShapeDeflection = Prs3d::GetDeflection (theShape, theDrawer);
+ Prs3d_NListOfSequenceOfPnt aPolylines;
+ addEdges (theShape, theDrawer, aShapeDeflection,
+ &aPolylines, &aPolylines, &aPolylines);
+ return Prs3d::PrimitivesFromPolylines (aPolylines);
+}
+
+// =========================================================================
+// function : addEdges
+// purpose :
+// =========================================================================
+void StdPrs_WFShape::addEdges (const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer,
+ Standard_Real theShapeDeflection,
+ Prs3d_NListOfSequenceOfPnt* theWire,
+ Prs3d_NListOfSequenceOfPnt* theFree,
+ Prs3d_NListOfSequenceOfPnt* theUnFree)
+{
+ if (theShape.IsNull())
+ {
+ return;
+ }
+
+ TopTools_ListOfShape aLWire, aLFree, aLUnFree;
+ TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
+ TopExp::MapShapesAndAncestors (theShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap);
+ for (TopTools_IndexedDataMapOfShapeListOfShape::Iterator anEdgeIter (anEdgeMap); anEdgeIter.More(); anEdgeIter.Next())
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Key());
+ const Standard_Integer aNbNeighbours = anEdgeIter.Value().Extent();
+ switch (aNbNeighbours)
{
- addVertices (thePresentation, aShapeVertices, theDrawer->PointAspect());
+ case 0:
+ {
+ if (theWire != NULL)
+ {
+ aLWire.Append (anEdge);
+ }
+ break;
+ }
+ case 1:
+ {
+ if (theFree != NULL)
+ {
+ aLFree.Append (anEdge);
+ }
+ break;
+ }
+ default:
+ {
+ if (theUnFree)
+ {
+ aLUnFree.Append (anEdge);
+ }
+ break;
+ }
}
}
+
+ if (!aLWire.IsEmpty())
+ {
+ addEdges (aLWire, theDrawer, theShapeDeflection, *theWire);
+ }
+ if (!aLFree.IsEmpty())
+ {
+ addEdges (aLFree, theDrawer, theShapeDeflection, *theFree);
+ }
+ if (!aLUnFree.IsEmpty())
+ {
+ addEdges (aLUnFree, theDrawer, theShapeDeflection, *theUnFree);
+ }
}
// =========================================================================
}
// =========================================================================
-// function : AddPoints
+// function : AddVertexes
// purpose :
// =========================================================================
-void StdPrs_WFShape::addVertices (const Handle (Prs3d_Presentation)& thePresentation,
- const TColgp_SequenceOfPnt& theVertices,
- const Handle (Prs3d_PointAspect)& theAspect)
+Handle(Graphic3d_ArrayOfPoints) StdPrs_WFShape::AddVertexes (const TopoDS_Shape& theShape,
+ Prs3d_VertexDrawMode theVertexMode)
{
- Standard_Integer aNbVertices = theVertices.Length();
- if (aNbVertices < 1)
+ TColgp_SequenceOfPnt aShapeVertices;
+ if (theVertexMode == Prs3d_VDM_All)
{
- return;
+ for (TopExp_Explorer aVertIter (theShape, TopAbs_VERTEX); aVertIter.More(); aVertIter.Next())
+ {
+ const TopoDS_Vertex& aVert = TopoDS::Vertex (aVertIter.Current());
+ aShapeVertices.Append (BRep_Tool::Pnt (aVert));
+ }
}
+ else
+ {
+ // isolated vertices
+ for (TopExp_Explorer aVertIter (theShape, TopAbs_VERTEX, TopAbs_EDGE); aVertIter.More(); aVertIter.Next())
+ {
+ const TopoDS_Vertex& aVert = TopoDS::Vertex (aVertIter.Current());
+ aShapeVertices.Append (BRep_Tool::Pnt (aVert));
+ }
- Handle(Graphic3d_ArrayOfPoints) aVertexArray = new Graphic3d_ArrayOfPoints (aNbVertices);
- for (Standard_Integer anI = 1; anI <= aNbVertices; ++anI)
+ // internal vertices
+ for (TopExp_Explorer anEdgeIter (theShape, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
+ {
+ for (TopoDS_Iterator aVertIter (anEdgeIter.Current(), Standard_False, Standard_True); aVertIter.More(); aVertIter.Next())
+ {
+ const TopoDS_Shape& aVertSh = aVertIter.Value();
+ if (aVertSh.Orientation() == TopAbs_INTERNAL
+ && aVertSh.ShapeType() == TopAbs_VERTEX)
+ {
+ const TopoDS_Vertex& aVert = TopoDS::Vertex (aVertSh);
+ aShapeVertices.Append (BRep_Tool::Pnt (aVert));
+ }
+ }
+ }
+ }
+
+ if (aShapeVertices.IsEmpty())
{
- aVertexArray->AddVertex (theVertices.Value (anI));
+ return Handle(Graphic3d_ArrayOfPoints)();
}
- Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
- aGroup->SetPrimitivesAspect (theAspect->Aspect());
- aGroup->AddPrimitiveArray (aVertexArray);
+ const Standard_Integer aNbVertices = aShapeVertices.Length();
+ Handle(Graphic3d_ArrayOfPoints) aVertexArray = new Graphic3d_ArrayOfPoints (aNbVertices);
+ for (Standard_Integer aVertIter = 1; aVertIter <= aNbVertices; ++aVertIter)
+ {
+ aVertexArray->AddVertex (aShapeVertices.Value (aVertIter));
+ }
+ return aVertexArray;
}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
+class Graphic3d_ArrayOfPoints;
+
//! Tool for computing wireframe presentation of a TopoDS_Shape.
class StdPrs_WFShape : public Prs3d_Root
{
const TopoDS_Shape& theShape,
const Standard_Boolean theToExcludeGeometric = Standard_True);
+ //! Compute all edges (wire, free, unfree) and put them into single primitive array.
+ //! @param theShape [in] the shape
+ //! @param theDrawer [in] the drawer settings (deviation angle and maximal parameter value)
+ Standard_EXPORT static Handle(Graphic3d_ArrayOfPrimitives) AddAllEdges (const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer);
+
+ //! Compute vertex presentation for a shape.
+ //! @param theShape [in] the shape
+ //! @param theVertexMode [in] vertex filter
+ Standard_EXPORT static Handle(Graphic3d_ArrayOfPoints) AddVertexes (const TopoDS_Shape& theShape,
+ Prs3d_VertexDrawMode theVertexMode);
+
private:
//! Compute edge presentations for a shape.
- //! @param theEdges [in] the list of edges.
- //! @param theDrawer [in] the drawer settings.
- //! @param theShapeDeflection [in] the deflection for the wireframe shape.
+ //! @param theShape [in] the shape
+ //! @param theDrawer [in] the drawer settings (deviation angle and maximal parameter value)
+ //! @param theShapeDeflection [in] the deflection for the wireframe shape
+ //! @param theWire [out] output polylines for lonely wires
+ //! @param theFree [out] output polylines for free edges
+ //! @param theUnFree [out] output polylines for non-free edges
+ Standard_EXPORT static void addEdges (const TopoDS_Shape& theShape,
+ const Handle(Prs3d_Drawer)& theDrawer,
+ Standard_Real theShapeDeflection,
+ Prs3d_NListOfSequenceOfPnt* theWire,
+ Prs3d_NListOfSequenceOfPnt* theFree,
+ Prs3d_NListOfSequenceOfPnt* theUnFree);
+
+ //! Compute edge presentations for a shape.
+ //! @param theEdges [in] the list of edges
+ //! @param theDrawer [in] the drawer settings (deviation angle and maximal parameter value)
+ //! @param theShapeDeflection [in] the deflection for the wireframe shape
+ //! @param thePolylines [out] output polylines
static void addEdges (const TopTools_ListOfShape& theEdges,
const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theShapeDeflection,
Prs3d_NListOfSequenceOfPnt& thePolylines);
- //! Compute vertex presentation for a shape.
- //! @param thePresentation [in] the presentation.
- //! @param theVertices [in] the list of points.
- //! @param theAspect [in] the point drawing aspect.
- static void addVertices (const Handle (Prs3d_Presentation)& thePresentation,
- const TColgp_SequenceOfPnt& theVertices,
- const Handle (Prs3d_PointAspect)& theAspect);
};
#endif // _StdPrs_WFShape_H__
}
else if (theArgNb >= 3)
{
- Graphic3d_Vec4 anRgba;
+ Graphic3d_Vec4 anRgba (0.0f, 0.0f, 0.0f, 1.0f);
Standard_Integer aNbComps = Min (theArgNb, theToParseAlpha ? 4 : 3);
for (int aCompIter = 0; aCompIter < aNbComps; ++aCompIter)
{
{
aGroup->SetGroupPrimitivesAspect (myMarkerAspect);
}
- aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
- aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
+ else
+ {
+ aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
+ }
aGroup->AddPrimitiveArray (myPArray);
}
aPrims->AddVertex (aPnts[aPntIter]);
}
- ViewerTest::Display (argv[1], new MyPArrayObject (aPrims));
+ Handle(AIS_InteractiveObject) aPrs = new MyPArrayObject (aPrims);
+ if (!isTri)
+ {
+ aPrs->Attributes()->SetupOwnShadingAspect();
+ aPrs->Attributes()->ShadingAspect()->Aspect()->SetColor (aPrs->Attributes()->LineAspect()->Aspect()->Color());
+ }
+ ViewerTest::Display (argv[1], aPrs);
return 0;
}
#include <Graphic3d_Group.hxx>
#include <Graphic3d_ShaderObject.hxx>
#include <Graphic3d_ShaderProgram.hxx>
-#include <OpenGl_AspectFace.hxx>
-#include <OpenGl_AspectLine.hxx>
-#include <OpenGl_AspectMarker.hxx>
-#include <OpenGl_AspectText.hxx>
+#include <OpenGl_Aspects.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_GlCore20.hxx>
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// To test linking against OpenGl_Workspace and all aspect classes
- const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker();
- aMA->Aspect()->Type();
- const OpenGl_AspectText* aTA = theWorkspace->AspectText();
- aTA->Aspect()->Font();
- OpenGl_Vec4 aColor = theWorkspace->LineColor();
+ const OpenGl_Aspects* aMA = theWorkspace->Aspects();
+ aMA->Aspect()->MarkerType();
+ OpenGl_Vec4 aColor = theWorkspace->InteriorColor();
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID,
Graphic3d_TOSM_UNLIT, Graphic3d_AlphaMode_Opaque, false,