- {
- if (!myAspect.IsNull())
- myAspect->SetColor (Quantity_Color (1.0, 1.0, 0.0, Quantity_TOC_RGB));
- myIsConflicting = false;
- }
-}
-
-void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
-{
- // this method is a combination of OCCT OpenGL functions. The main purpose is to have
- // equal distance from the source object to symbol indpendently of zoom.
- // It is base on OCCT 6.9.1 and might need changes when using later OCCT versions.
- // The specific SHAPER modifications are marked by ShaperModification:start/end, other is OCCT code
-
- // do not update presentation for invalid or already removed objects: the presentation
- // should be removed soon
- if (!myConstraint->data().get() || !myConstraint->data()->isValid())
- return;
-
- const OpenGl_AspectMarker* anAspectMarker = theWorkspace->AspectMarker(Standard_True);
- const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
- Handle(OpenGl_View) aView = theWorkspace->ActiveView();
-
- // ShaperModification:start
- double aScale = aView->Camera()->Scale();
- // Update points coordinate taking the viewer scale into account
- if (!updatePoints(MyDist * aScale))
- return;
- // ShaperModification:end
-
- Handle(Graphic3d_Buffer) aAttribs = myPntArray->Attributes();
-
- if (myVboAttribs.IsNull()) {
- myVboAttribs = new SketcherPrs_VertexBuffer(*aAttribs);
- }
-
- // Update drawing attributes
- if (!myVboAttribs->init(aCtx, 0, aAttribs->NbElements, aAttribs->Data(), GL_NONE, aAttribs->Stride)) {
- myVboAttribs->Release (aCtx.operator->());
- myVboAttribs.Nullify();
- return;
- }
-
- Handle(OpenGl_Texture) aTextureBack = theWorkspace->DisableTexture();
-
- const Handle(OpenGl_PointSprite)& aSpriteNorm = anAspectMarker->SpriteRes(aCtx);
-
- if (!aSpriteNorm.IsNull() && !aSpriteNorm->IsDisplayList()) {
- // ShaperModification:start : filling the presentation with color if there is a conflict
- const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0 || myIsConflicting;
- // ShaperModification:end
-
- const Handle(OpenGl_PointSprite)& aSprite = (toHilight && anAspectMarker->SpriteHighlightRes(aCtx)->IsValid())
- ? anAspectMarker->SpriteHighlightRes(aCtx)
- : aSpriteNorm;
- theWorkspace->EnableTexture (aSprite);
- aCtx->ShaderManager()->BindProgram(anAspectMarker, aSprite, Standard_False, Standard_False, anAspectMarker->ShaderProgramRes(aCtx));
- const TEL_COLOUR* aLineColor = &anAspectMarker->Color();
- if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
- aLineColor = theWorkspace->HighlightColor;
-
- // Set lighting of the symbol
- if (toHilight)
- aCtx->core11fwd->glDisable (GL_LIGHTING);
- else
- aCtx->core11fwd->glEnable (GL_LIGHTING);
-
- aCtx->SetColor4fv(*(const OpenGl_Vec4* )(aLineColor->rgb));
-
-
- myVboAttribs->BindAllAttributes(aCtx);
- // Textured markers will be drawn with the point sprites
- aCtx->SetPointSize (anAspectMarker->MarkerSize());
- aCtx->core11fwd->glEnable (GL_ALPHA_TEST);
- aCtx->core11fwd->glAlphaFunc (GL_GEQUAL, 0.1f);
-
- aCtx->core11fwd->glEnable (GL_BLEND);
- aCtx->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);