// Get texture parameters
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
- const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace (Standard_False);
+ const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace();
GLfloat aTextureWidth = (GLfloat )anAspectFace->TextureRes (aCtx)->SizeX();
GLfloat aTextureHeight = (GLfloat )anAspectFace->TextureRes (aCtx)->SizeY();
}
// remember current aspect face defined in workspace
- const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace (Standard_False);
+ const OpenGl_AspectFace* aFaceAsp = theWorkspace->AspectFace();
// replace primitive groups rendering filter
Handle(OpenGl_RenderFilter) aRenderFilter = theWorkspace->GetRenderFilter();
// override aspects, disable culling
theWorkspace->SetAspectFace (&theWorkspace->NoneCulling());
- theWorkspace->AspectFace (Standard_True);
+ theWorkspace->ApplyAspectFace();
// evaluate number of pair faces
glDisable (GL_DEPTH_TEST);
// override material, cull back faces
theWorkspace->SetAspectFace (&theWorkspace->FrontCulling());
- theWorkspace->AspectFace (Standard_True);
+ theWorkspace->ApplyAspectFace();
// enable all clip plane except the rendered one
for (aPlaneIt.Init (aContextPlanes); aPlaneIt.More(); aPlaneIt.Next())
aPlaneRes->Update (aContext);
- const OpenGl_AspectFace* aFaceAspect = theWorkspace->AspectFace (Standard_False);
+ const OpenGl_AspectFace* aFaceAspect = theWorkspace->AspectFace();
const OpenGl_AspectFace* aPlaneAspect = aPlaneRes->AspectFace();
if (aPlaneAspect != NULL)
{
// function : SetShadingMaterial
// purpose :
// =======================================================================
-void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect)
+void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
+ const OpenGl_Vec4* theHighlightColor)
{
if (!myActiveProgram.IsNull())
{
: theAspect->IntBack();
aParams.Init (aProp);
aParams.Diffuse.a() = aProp.trans;
+
+ if (theHighlightColor != NULL)
+ {
+ aParams.SetColor (*theHighlightColor);
+ }
+
myActiveProgram->SetUniform (this, aLoc, OpenGl_Material::NbOfVec4(),
aParams.Packed());
}
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_AspectFace* theAspect,
+ const OpenGl_Vec4* theHighlightColor = NULL);
//! Setup current color.
Standard_EXPORT void SetColor4fv (const OpenGl_Vec4& theColor);
Standard_ExtCharacter anAxesState = getGridAxes (aCorners, aGridAxes);
// Remember current aspects
- const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine (Standard_False);
- const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText (Standard_False);
+ const OpenGl_AspectLine* anOldAspectLine = theWorkspace->AspectLine();
+ const OpenGl_AspectText* anOldAspectText = theWorkspace->AspectText();
OpenGl_Mat4 aModelMatrix;
aModelMatrix.Convert (aContext->WorldViewState.Current());
const Handle(OpenGl_RenderFilter)& aFilter = theWorkspace->GetRenderFilter();
// Setup aspects
- const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine (Standard_False);
- const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace (Standard_False);
- const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker (Standard_False);
- const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText (Standard_False);
+ const OpenGl_AspectLine* aBackAspectLine = theWorkspace->AspectLine();
+ const OpenGl_AspectFace* aBackAspectFace = theWorkspace->AspectFace();
+ const OpenGl_AspectMarker* aBackAspectMarker = theWorkspace->AspectMarker();
+ const OpenGl_AspectText* aBackAspectText = theWorkspace->AspectText();
Standard_Boolean isLineSet = myAspectLine && myAspectLine->RenderFiltered (theWorkspace, aFilter);
Standard_Boolean isFaceSet = myAspectFace && myAspectFace->RenderFiltered (theWorkspace, aFilter);
Standard_Boolean isMarkerSet = myAspectMarker && myAspectMarker->RenderFiltered (theWorkspace, aFilter);
#define _OpenGl_NamedStatus_Header
// Dynamic fields
-#define OPENGL_NS_HIGHLIGHT (1<<1)
#define OPENGL_NS_RESMAT (1<<2)
#define OPENGL_NS_TEXTURE (1<<4)
#define OPENGL_NS_ANTIALIASING (1<<5)
const Standard_Boolean theHasVertColor) const
{
const Handle(OpenGl_Context)& aGlContext = theWorkspace->GetGlContext();
- const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0;
+ const bool toHilight = theWorkspace->ToHighlight();
bool hasVColors = theHasVertColor && !toHilight;
if (myVboAttribs.IsNull())
{
}
#endif
- const OpenGl_AspectLine* anAspectLineOld = NULL;
-
- anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace (Standard_True)->AspectEdge());
- const OpenGl_AspectLine* anAspect = theWorkspace->AspectLine (Standard_True);
+ const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
+ const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
#if !defined(GL_ES_VERSION_2_0)
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
// =======================================================================
void OpenGl_PrimitiveArray::drawMarkers (const Handle(OpenGl_Workspace)& theWorkspace) const
{
- const OpenGl_AspectMarker* anAspectMarker = theWorkspace->AspectMarker (Standard_True);
+ const OpenGl_AspectMarker* anAspectMarker = theWorkspace->ApplyAspectMarker();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
const Handle(OpenGl_PointSprite)& aSpriteNorm = anAspectMarker->SpriteRes (aCtx);
if (!aSpriteNorm.IsNull()
return;
}
- const OpenGl_AspectFace* anAspectFace = theWorkspace->AspectFace (Standard_True);
- const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
- const OpenGl_AspectMarker* anAspectMarker = theWorkspace->AspectMarker (myDrawMode == GL_POINTS);
+ const OpenGl_AspectFace* anAspectFace = theWorkspace->ApplyAspectFace();
+ const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
+ const OpenGl_AspectMarker* anAspectMarker = myDrawMode == GL_POINTS
+ ? theWorkspace->ApplyAspectMarker()
+ : theWorkspace->AspectMarker();
// create VBOs on first render call
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
}
Tint aFrontLightingModel = anAspectFace->IntFront().color_mask;
- const TEL_COLOUR* anInteriorColor = &anAspectFace->IntFront().matcol;
- const TEL_COLOUR* anEdgeColor = &anAspectFace->AspectEdge()->Color();
- const TEL_COLOUR* aLineColor = myDrawMode == GL_POINTS ? &anAspectMarker->Color() : &anAspectLine->Color();
-
- // Use highlight colors
- if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
- {
- anEdgeColor = anInteriorColor = aLineColor = theWorkspace->HighlightColor;
- aFrontLightingModel = 0;
- }
-
const Standard_Boolean hasColorAttrib = !myVboAttribs.IsNull()
&& myVboAttribs->HasColorAttribute();
const Standard_Boolean isLightOn = aFrontLightingModel != 0
if ((myDrawMode > GL_LINE_STRIP && anAspectFace->InteriorStyle() != Aspect_IS_EMPTY) ||
(myDrawMode <= GL_LINE_STRIP))
{
- const bool toHilight = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) != 0;
- const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->InteriorStyle() != Aspect_IS_HIDDENLINE
- ? myBounds->Colors
- : NULL;
+ const bool toHilight = theWorkspace->ToHighlight();
const Standard_Boolean hasVertColor = hasColorAttrib && !toHilight;
if (aCtx->core20fwd != NULL)
{
// All primitives should gather material properties from the AspectFace in shading mode
if (isLightOn)
{
- aCtx->SetShadingMaterial (anAspectFace);
+ aCtx->SetShadingMaterial (anAspectFace, theWorkspace->ToHighlight() ? (const OpenGl_Vec4* )theWorkspace->HighlightColor : NULL);
}
if (!theWorkspace->ActiveTexture().IsNull()
aCtx->SetTextureMatrix (theWorkspace->ActiveTexture()->GetParams());
}
- aCtx->SetColor4fv (*(const OpenGl_Vec4* )(myDrawMode <= GL_LINE_STRIP ? aLineColor->rgb : anInteriorColor->rgb));
+ if (myDrawMode <= GL_LINE_STRIP)
+ {
+ const TEL_COLOUR& aLineColor = myDrawMode == GL_POINTS ? theWorkspace->MarkerColor() : theWorkspace->LineColor();
+ aCtx->SetColor4fv (*(const OpenGl_Vec4* )aLineColor.rgb);
+ }
+ else
+ {
+ const TEL_COLOUR& anInteriorColor = theWorkspace->InteriorColor();
+ aCtx->SetColor4fv (*(const OpenGl_Vec4* )anInteriorColor.rgb);
+ }
if (myDrawMode == GL_LINES
|| myDrawMode == GL_LINE_STRIP)
{
aCtx->SetLineWidth (anAspectLine->Width());
}
+ const Graphic3d_Vec4* aFaceColors = !myBounds.IsNull() && !toHilight && anAspectFace->InteriorStyle() != Aspect_IS_HIDDENLINE
+ ? myBounds->Colors
+ : NULL;
drawArray (theWorkspace, aFaceColors, hasColorAttrib);
}
if (anAspectFace->Edge()
|| anAspectFace->InteriorStyle() == Aspect_IS_HIDDENLINE)
{
+ const TEL_COLOUR* anEdgeColor = &theWorkspace->EdgeColor();
drawEdges (anEdgeColor, theWorkspace);
// restore OpenGL polygon mode if needed
{
#if !defined(GL_ES_VERSION_2_0)
// Apply line aspect
- const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
glDisable (GL_LIGHTING);
// Use highlight colors
- theWorkspace->GetGlContext()->core11->glColor3fv ((theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT) ? theWorkspace->HighlightColor->rgb : anAspectLine->Color().rgb);
+ theWorkspace->GetGlContext()->core11->glColor3fv (theWorkspace->LineColor().rgb);
glEnableClientState (GL_VERTEX_ARRAY);
glVertexPointer (3, GL_FLOAT, 0, (GLfloat* )&myVerts);
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
// Render named status
- const Standard_Integer aNamedStatus = theWorkspace->NamedStatus;
if (highlight)
{
- theWorkspace->NamedStatus |= OPENGL_NS_HIGHLIGHT;
+ theWorkspace->SetHighlight (true);
}
// Apply local transformation
// Take into account transform persistence
aCtx->ApplyModelViewMatrix();
- // Apply aspects
- const OpenGl_AspectLine *anAspectLine = theWorkspace->AspectLine (Standard_False);
- const OpenGl_AspectFace *anAspectFace = theWorkspace->AspectFace (Standard_False);
- const OpenGl_AspectMarker *anAspectMarker = theWorkspace->AspectMarker (Standard_False);
- const OpenGl_AspectText *anAspectText = theWorkspace->AspectText (Standard_False);
+ // 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();
// Apply correction for mirror transform
if (myIsMirrored)
theWorkspace->HighlightColor = aHighlightColor;
// Restore aspects
- theWorkspace->SetAspectLine (anAspectLine);
- theWorkspace->SetAspectFace (anAspectFace);
- theWorkspace->SetAspectMarker (anAspectMarker);
- theWorkspace->SetAspectText (anAspectText);
+ theWorkspace->SetAspectLine (aPrevAspectLine);
+ theWorkspace->SetAspectFace (aPrevAspectFace);
+ theWorkspace->SetAspectMarker (aPrevAspectMarker);
+ theWorkspace->SetAspectText (aPrevAspectText);
// Apply highlight box
if (!myHighlightBox.IsNull())
}
// Restore named status
- theWorkspace->NamedStatus = aNamedStatus;
+ theWorkspace->SetHighlight (false);
}
// =======================================================================
// =======================================================================
void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
- const OpenGl_AspectText* aTextAspect = theWorkspace->AspectText (Standard_True);
+ const OpenGl_AspectText* aTextAspect = theWorkspace->ApplyAspectText();
const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext();
myProjMatrix.Convert (aCtx->ProjectionState.Current());
// use highlight color or colors from aspect
- if (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT)
- {
- render (theWorkspace->PrinterContext(),
- aCtx,
- *aTextAspect,
- *theWorkspace->HighlightColor,
- *theWorkspace->HighlightColor,
- theWorkspace->View()->RenderingParams().Resolution);
- }
- else
- {
- render (theWorkspace->PrinterContext(),
- aCtx,
- *aTextAspect,
- aTextAspect->Color(),
- aTextAspect->SubtitleColor(),
- theWorkspace->View()->RenderingParams().Resolution);
- }
+ render (theWorkspace->PrinterContext(),
+ aCtx,
+ *aTextAspect,
+ theWorkspace->TextColor(),
+ theWorkspace->TextSubtitleColor(),
+ theWorkspace->View()->RenderingParams().Resolution);
aCtx->BindProgram (NULL);
OpenGl_Mat4d aModelViewZ (aModelMatrix);
// Set line aspect
- const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->AspectLine (Standard_True);
+ const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->ApplyAspectLine();
CALL_DEF_CONTEXTLINE aLineAspect = {1, 1, { 1.F, 1.F, 1.F }, aCurrentAspectLine->Type(), aCurrentAspectLine->Width(), 0};
aLineAspect.Color.r = myZColor.r();
aLineAspect.Color.g = myZColor.g();
const GLdouble aScale = myScale * myRatio;
- const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
+ const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
const TEL_COLOUR& aLineColor = anAspectLine->Color();
// Create the trihedron
myUseDepthWrite (Standard_True),
myUseGLLight (Standard_True),
//
- AspectLine_set (&myDefaultAspectLine),
- AspectLine_applied (NULL),
- AspectFace_set (&myDefaultAspectFace),
- AspectFace_applied (NULL),
- AspectMarker_set (&myDefaultAspectMarker),
- AspectMarker_applied (NULL),
- AspectText_set (&myDefaultAspectText),
- AspectText_applied (NULL),
+ myAspectLineSet (&myDefaultAspectLine),
+ myAspectFaceSet (&myDefaultAspectFace),
+ myAspectFaceApplied (NULL),
+ myAspectMarkerSet (&myDefaultAspectMarker),
+ myAspectMarkerApplied (NULL),
+ myAspectTextSet (&myDefaultAspectText),
+ myAspectFaceAppliedWithHL (false),
+ //
ViewMatrix_applied (&myDefaultMatrix),
StructureMatrix_applied (&myDefaultMatrix),
myCullingMode (TelCullUndefined),
+ myToHighlight (false),
myModelViewMatrix (myDefaultMatrix),
PolygonOffset_applied (THE_DEFAULT_POFFSET)
{
NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0;
HighlightColor = &THE_WHITE_COLOR;
- AspectLine_set = &myDefaultAspectLine;
- AspectLine_applied = NULL;
- AspectFace_set = &myDefaultAspectFace;
- AspectFace_applied = NULL;
- AspectMarker_set = &myDefaultAspectMarker;
- AspectMarker_applied = NULL;
- AspectText_set = &myDefaultAspectText;
- AspectText_applied = NULL;
-
+ myAspectLineSet = &myDefaultAspectLine;
+ myAspectFaceSet = &myDefaultAspectFace;
+ myAspectFaceApplied = NULL;
+ myAspectMarkerSet = &myDefaultAspectMarker;
+ myAspectMarkerApplied = NULL;
+ myAspectTextSet = &myDefaultAspectText;
PolygonOffset_applied = THE_DEFAULT_POFFSET;
myCullingMode = TelCullUndefined;
- AspectLine(Standard_True);
- AspectFace(Standard_True);
- AspectMarker(Standard_True);
- AspectText(Standard_True);
+ ApplyAspectLine();
+ ApplyAspectFace();
+ ApplyAspectMarker();
+ ApplyAspectText();
myGlContext->SetTypeOfLine (myDefaultAspectLine.Type());
myGlContext->SetLineWidth (myDefaultAspectLine.Width());
void OpenGl_Workspace::updateMaterial (const int theFlag)
{
// Case of hidden line
- if (AspectFace_set->InteriorStyle() == Aspect_IS_HIDDENLINE)
+ if (myAspectFaceSet->InteriorStyle() == Aspect_IS_HIDDENLINE)
{
- myAspectFaceHl = *AspectFace_set; // copy all values including line edge aspect
+ myAspectFaceHl = *myAspectFaceSet; // copy all values including line edge aspect
myAspectFaceHl.ChangeIntFront().matcol = myView->BackgroundColor();
myAspectFaceHl.ChangeIntFront().color_mask = 0;
myAspectFaceHl.ChangeIntFront().color_mask = 0;
- AspectFace_set = &myAspectFaceHl;
+ myAspectFaceSet = &myAspectFaceHl;
return;
}
- const OPENGL_SURF_PROP* aProps = &AspectFace_set->IntFront();
+ const OPENGL_SURF_PROP* aProps = &myAspectFaceSet->IntFront();
GLenum aFace = GL_FRONT_AND_BACK;
if (theFlag == TEL_BACK_MATERIAL)
{
aFace = GL_BACK;
- aProps = &AspectFace_set->IntBack();
+ aProps = &myAspectFaceSet->IntBack();
}
- else if (AspectFace_set->DistinguishingMode() == TOn
+ else if (myAspectFaceSet->DistinguishingMode() == TOn
&& !(NamedStatus & OPENGL_NS_RESMAT))
{
aFace = GL_FRONT;
}
myMatTmp.Init (*aProps);
+ if (myToHighlight)
+ {
+ myMatTmp.SetColor (*(const OpenGl_Vec4* )HighlightColor);
+ }
// handling transparency
if (NamedStatus & OPENGL_NS_2NDPASSDO)
// function : SetAspectLine
// purpose :
// =======================================================================
-const OpenGl_AspectLine * OpenGl_Workspace::SetAspectLine(const OpenGl_AspectLine *AnAspect)
+const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
{
- const OpenGl_AspectLine *AspectLine_old = AspectLine_set;
- AspectLine_set = AnAspect;
- return AspectLine_old;
+ const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
+ myAspectLineSet = theAspect;
+ return aPrevAspectLine;
}
// =======================================================================
// function : SetAspectFace
// purpose :
// =======================================================================
-const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace(const OpenGl_AspectFace *AnAspect)
+const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
{
- const OpenGl_AspectFace *AspectFace_old = AspectFace_set;
- AspectFace_set = AnAspect;
- return AspectFace_old;
+ const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
+ myAspectFaceSet = theAspect;
+ return aPrevAspectFace;
}
// =======================================================================
// function : SetAspectMarker
// purpose :
// =======================================================================
-const OpenGl_AspectMarker * OpenGl_Workspace::SetAspectMarker(const OpenGl_AspectMarker *AnAspect)
+const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
{
- const OpenGl_AspectMarker *AspectMarker_old = AspectMarker_set;
- AspectMarker_set = AnAspect;
- return AspectMarker_old;
+ const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
+ myAspectMarkerSet = theAspect;
+ return aPrevAspectMarker;
}
// =======================================================================
// function : SetAspectText
// purpose :
// =======================================================================
-const OpenGl_AspectText * OpenGl_Workspace::SetAspectText(const OpenGl_AspectText *AnAspect)
+const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
{
- const OpenGl_AspectText *AspectText_old = AspectText_set;
- AspectText_set = AnAspect;
- return AspectText_old;
-}
-
-// =======================================================================
-// function : AspectLine
-// purpose :
-// =======================================================================
-const OpenGl_AspectLine * OpenGl_Workspace::AspectLine(const Standard_Boolean theWithApply)
-{
- if (theWithApply)
- {
- AspectLine_applied = AspectLine_set;
- }
-
- return AspectLine_set;
+ const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
+ myAspectTextSet = theAspect;
+ return aPrevAspectText;
}
// =======================================================================
-// function : AspectFace
+// function : ApplyAspectFace
// purpose :
// =======================================================================
-const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean theToApply)
+const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
{
- if (!theToApply)
- {
- return AspectFace_set;
- }
-
if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
{
// manage back face culling mode, disable culling when clipping is enabled
TelCullMode aCullingMode = (myGlContext->Clipping().IsClippingOrCappingOn()
- || AspectFace_set->InteriorStyle() == Aspect_IS_HATCH)
+ || myAspectFaceSet->InteriorStyle() == Aspect_IS_HATCH)
? TelCullNone
- : (TelCullMode )AspectFace_set->CullingMode();
+ : (TelCullMode )myAspectFaceSet->CullingMode();
if (aCullingMode != TelCullNone
&& !(NamedStatus & OPENGL_NS_2NDPASSDO))
{
// disable culling in case of translucent shading aspect
- if (AspectFace_set->IntFront().trans != 1.0f)
+ if (myAspectFaceSet->IntFront().trans != 1.0f)
{
aCullingMode = TelCullNone;
}
}
}
- if (AspectFace_set == AspectFace_applied)
+ if (myAspectFaceSet == myAspectFaceApplied
+ && myToHighlight == myAspectFaceAppliedWithHL)
{
- return AspectFace_set;
+ return myAspectFaceSet;
}
+ myAspectFaceAppliedWithHL = myToHighlight;
#if !defined(GL_ES_VERSION_2_0)
- const Aspect_InteriorStyle anIntstyle = AspectFace_set->InteriorStyle();
- if (AspectFace_applied == NULL || AspectFace_applied->InteriorStyle() != anIntstyle)
+ const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->InteriorStyle();
+ if (myAspectFaceApplied == NULL
+ || myAspectFaceApplied->InteriorStyle() != anIntstyle)
{
switch (anIntstyle)
{
case Aspect_IS_HATCH:
{
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
- myLineAttribs->SetTypeOfHatch (AspectFace_applied != NULL ? AspectFace_applied->Hatch() : TEL_HS_SOLID);
+ myLineAttribs->SetTypeOfHatch (myAspectFaceApplied != NULL ? myAspectFaceApplied->Hatch() : TEL_HS_SOLID);
break;
}
case Aspect_IS_SOLID:
if (anIntstyle == Aspect_IS_HATCH)
{
- const Tint hatchstyle = AspectFace_set->Hatch();
- if (AspectFace_applied == NULL || AspectFace_applied->Hatch() != hatchstyle)
+ const Tint hatchstyle = myAspectFaceSet->Hatch();
+ if (myAspectFaceApplied == NULL
+ || myAspectFaceApplied->Hatch() != hatchstyle)
{
myLineAttribs->SetTypeOfHatch (hatchstyle);
}
#endif
// Aspect_POM_None means: do not change current settings
- if ((AspectFace_set->PolygonOffset().mode & Aspect_POM_None) != Aspect_POM_None)
+ if ((myAspectFaceSet->PolygonOffset().mode & Aspect_POM_None) != Aspect_POM_None)
{
- if (PolygonOffset_applied.mode != AspectFace_set->PolygonOffset().mode
- || PolygonOffset_applied.factor != AspectFace_set->PolygonOffset().factor
- || PolygonOffset_applied.units != AspectFace_set->PolygonOffset().units)
+ if (PolygonOffset_applied.mode != myAspectFaceSet->PolygonOffset().mode
+ || PolygonOffset_applied.factor != myAspectFaceSet->PolygonOffset().factor
+ || PolygonOffset_applied.units != myAspectFaceSet->PolygonOffset().units)
{
- SetPolygonOffset (AspectFace_set->PolygonOffset().mode,
- AspectFace_set->PolygonOffset().factor,
- AspectFace_set->PolygonOffset().units);
+ SetPolygonOffset (myAspectFaceSet->PolygonOffset().mode,
+ myAspectFaceSet->PolygonOffset().factor,
+ myAspectFaceSet->PolygonOffset().units);
}
}
updateMaterial (TEL_FRONT_MATERIAL);
- if (AspectFace_set->DistinguishingMode() == TOn)
+ if (myAspectFaceSet->DistinguishingMode() == TOn)
{
updateMaterial (TEL_BACK_MATERIAL);
}
- if (AspectFace_set->DoTextureMap())
+ if (myAspectFaceSet->DoTextureMap())
{
- EnableTexture (AspectFace_set->TextureRes (myGlContext),
- AspectFace_set->TextureParams());
+ EnableTexture (myAspectFaceSet->TextureRes (myGlContext),
+ myAspectFaceSet->TextureParams());
}
else
{
}
}
- AspectFace_applied = AspectFace_set;
- return AspectFace_set;
+ myAspectFaceApplied = myAspectFaceSet;
+ return myAspectFaceSet;
}
//=======================================================================
}
// =======================================================================
-// function : AspectMarker
+// function : ApplyAspectMarker
// purpose :
// =======================================================================
-const OpenGl_AspectMarker* OpenGl_Workspace::AspectMarker (const Standard_Boolean theToApply)
+const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
{
- if (theToApply && (AspectMarker_set != AspectMarker_applied))
+ if (myAspectMarkerSet != myAspectMarkerApplied)
{
- if (!AspectMarker_applied || (AspectMarker_set->Scale() != AspectMarker_applied->Scale()))
+ if (myAspectMarkerApplied == NULL
+ || (myAspectMarkerSet->Scale() != myAspectMarkerApplied->Scale()))
{
#if !defined(GL_ES_VERSION_2_0)
- glPointSize (AspectMarker_set->Scale());
+ glPointSize (myAspectMarkerSet->Scale());
#ifdef HAVE_GL2PS
- gl2psPointSize (AspectMarker_set->Scale());
+ gl2psPointSize (myAspectMarkerSet->Scale());
#endif
#endif
}
- AspectMarker_applied = AspectMarker_set;
- }
- return AspectMarker_set;
-}
-
-// =======================================================================
-// function : AspectText
-// purpose :
-// =======================================================================
-const OpenGl_AspectText* OpenGl_Workspace::AspectText (const Standard_Boolean theWithApply)
-{
- if (theWithApply)
- {
- AspectText_applied = AspectText_set;
+ myAspectMarkerApplied = myAspectMarkerSet;
}
-
- return AspectText_set;
+ return myAspectMarkerSet;
}
// =======================================================================
#include <OpenGl_Vec.hxx>
#include <OpenGl_Window.hxx>
-class OpenGl_AspectLine;
-class OpenGl_AspectMarker;
-class OpenGl_AspectText;
-class OpenGl_Element;
class OpenGl_View;
class Image_PixMap;
Standard_ShortReal Transparency() const { return Params.y(); }
Standard_ShortReal& ChangeTransparency() { return Params.y(); }
+ //! Set material color.
+ void SetColor (const OpenGl_Vec4& theColor)
+ {
+ // apply the same formula as in Graphic3d_MaterialAspect::SetColor()
+ Ambient.xyz() = theColor.rgb() * 0.25f;
+ Diffuse.xyz() = theColor.rgb();
+ }
+
//! Initialize material
void Init (const OPENGL_SURF_PROP& theProps);
const TEL_COLOUR* HighlightColor;
+ //! Return true if following structures should apply highlight color.
+ bool ToHighlight() const { return myToHighlight; }
+
+ //! Set highlight.
+ void SetHighlight (bool theToHighlight) { myToHighlight = theToHighlight; }
+
+ //! Return line color taking into account highlight flag.
+ const TEL_COLOUR& LineColor() const
+ {
+ return myToHighlight
+ ? *HighlightColor
+ : myAspectLineSet->Color();
+ }
+
+ //! Return edge color taking into account highlight flag.
+ const TEL_COLOUR& EdgeColor() const
+ {
+ return myToHighlight
+ ? *HighlightColor
+ : myAspectFaceSet->AspectEdge()->Color();
+ }
+
+ //! Return marker color taking into account highlight flag.
+ const TEL_COLOUR& MarkerColor() const
+ {
+ return myToHighlight
+ ? *HighlightColor
+ : myAspectMarkerSet->Color();
+ }
+
+ //! Return Interior color taking into account highlight flag.
+ const TEL_COLOUR& InteriorColor() const
+ {
+ return myToHighlight
+ ? *HighlightColor
+ : myAspectFaceSet->IntFront().matcol;
+ }
+
+ //! Return text color taking into account highlight flag.
+ const TEL_COLOUR& TextColor() const
+ {
+ return myToHighlight
+ ? *HighlightColor
+ : myAspectTextSet->Color();
+ }
+
+ //! Return text Subtitle color taking into account highlight flag.
+ const TEL_COLOUR& TextSubtitleColor() const
+ {
+ return myToHighlight
+ ? *HighlightColor
+ : myAspectTextSet->SubtitleColor();
+ }
+
+ //! 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 marker aspect (can differ from applied).
+ const OpenGl_AspectMarker* AspectMarker() const { return myAspectMarkerSet; }
+
+ //! 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);
- //// THESE METHODS ARE EXPORTED AS THEY PROVIDE STATE INFO TO USERDRAW
- Standard_EXPORT const OpenGl_AspectLine* AspectLine (const Standard_Boolean theWithApply);
- Standard_EXPORT const OpenGl_AspectFace* AspectFace (const Standard_Boolean theWithApply);
- Standard_EXPORT const OpenGl_AspectMarker* AspectMarker (const Standard_Boolean theWithApply);
- Standard_EXPORT const OpenGl_AspectText* AspectText (const Standard_Boolean theWithApply);
+ //! 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; }
- //! Clear the applied aspect state.
+ //! Clear the applied aspect state to default values.
void ResetAppliedAspect();
Standard_EXPORT Handle(OpenGl_Texture) DisableTexture();
Handle(OpenGl_RenderFilter) myRenderFilter;
Handle(OpenGl_Texture) myTextureBound; //!< currently bound texture (managed by OpenGl_AspectFace and OpenGl_View environment texture)
- const OpenGl_AspectLine *AspectLine_set, *AspectLine_applied;
- const OpenGl_AspectFace *AspectFace_set, *AspectFace_applied;
- const OpenGl_AspectMarker *AspectMarker_set, *AspectMarker_applied;
- const OpenGl_AspectText *AspectText_set, *AspectText_applied;
+ const OpenGl_AspectLine* myAspectLineSet;
+ const OpenGl_AspectFace* myAspectFaceSet;
+ const OpenGl_AspectFace* myAspectFaceApplied;
+ const OpenGl_AspectMarker* myAspectMarkerSet;
+ const OpenGl_AspectMarker* myAspectMarkerApplied;
+ const OpenGl_AspectText* myAspectTextSet;
+ bool myAspectFaceAppliedWithHL;
const OpenGl_Matrix* ViewMatrix_applied;
const OpenGl_Matrix* StructureMatrix_applied;
OpenGl_Material myMatBack; //!< current back material state
OpenGl_Material myMatTmp; //!< temporary variable
TelCullMode myCullingMode; //!< back face culling mode, applied from face aspect
+ bool myToHighlight; //!< flag indicating highlighting mode
OpenGl_Matrix myModelViewMatrix; //!< Model matrix with applied structure transformations
aCtx->BindProgram (NULL);
// To test linking against OpenGl_Workspace and all aspect classes
- const OpenGl_AspectLine* aLA = theWorkspace->AspectLine(0);
- const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker(0);
+ const OpenGl_AspectMarker* aMA = theWorkspace->AspectMarker();
aMA->Type();
- const OpenGl_AspectText* aTA = theWorkspace->AspectText(0);
+ const OpenGl_AspectText* aTA = theWorkspace->AspectText();
aTA->FontName();
- TEL_COLOUR aColor = theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT ?
- *(theWorkspace->HighlightColor) : aLA->Color();
+ TEL_COLOUR aColor = theWorkspace->LineColor();
// Finally draw something to make sure UserDraw really works
glPushAttrib(GL_ENABLE_BIT);
vmoveto 0 0
vmoveto 0 0
-checkcolor ${x1} ${y} ${White_R} ${White_G} ${White_B}
-checkcolor ${x2} ${y} ${White_R} ${White_G} ${White_B}
+if { [vreadpixel $x1 $y rgb name] != "IVORY" || [vreadpixel $x2 $y rgb name] != "IVORY" } {
+ Error: unexpected color of not selected object
+}
vmoveto ${x1} ${y}
vmoveto ${x1} ${y}
-checkcolor ${x1} ${y} ${Select_R} ${Select_G} ${Select_B}
-checkcolor ${x2} ${y} ${White_R} ${White_G} ${White_B}
+if { [vreadpixel $x1 $y rgb name] != "WHITE" } {
+ Error: unexpected color of selected object
+}
+if { [vreadpixel $x2 $y rgb name] != "IVORY" } {
+ Error: unexpected color of not selected object
+}
vmoveto ${x2} ${y}
vmoveto ${x2} ${y}
-checkcolor ${x1} ${y} ${White_R} ${White_G} ${White_B}
-checkcolor ${x2} ${y} ${Select_R} ${Select_G} ${Select_B}
+if { [vreadpixel $x1 $y rgb name] != "IVORY" } {
+ Error: unexpected color of not selected object
+}
+if { [vreadpixel $x2 $y rgb name] != "WHITE" } {
+ Error: unexpected color of selected object
+}
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
-
vselect 40 120 185 320 -allowoverlap 1
set aColor [vreadpixel 120 200 rgb name]
-if {$aColor != "GRAY80"} {
+if {$aColor != "GRAY66"} {
puts "ERROR: the circle is not selected with overlap mode activated"
}
vselmode 0 1
vmoveto 200 200
-if {[vreadpixel 197 257 name] != "CYAN1 1"} {
+if {[vreadpixel 197 257 rgb name] != "CYAN1"} {
puts "ERROR: presentation for dynamic highlight of the object is wrong!"
}
vmoveto 0 0
-if {[vreadpixel 197 257 name] != "BLUE2 1"} {
+if {[vreadpixel 197 257 rgb name] != "BLUE2"} {
puts "ERROR: the object is not unhighlighted after dynamic highlight!"
}
vselect 200 200
-if {[vreadpixel 197 257 name] != "GRAY80 1"} {
+if {[vreadpixel 197 257 rgb name] != "GRAY93"} {
puts "ERROR: presentation for selection highlight is wrong!"
}
vselect 0 0
-if {[vreadpixel 197 257 name] != "BLUE2 1"} {
+if {[vreadpixel 197 257 rgb name] != "BLUE2"} {
puts "ERROR: the object is not unhighlighted after selection highlight!"
}
puts "ERROR: wrong inital location"
}
vsetlocation b 0.5 0 0
-if {[vreadpixel 350 140 rgb name] != "CYAN1"} {
+if {[vreadpixel 350 140 rgb name] != "DARKTURQUOISE"} {
puts "ERROR: the transformation was not applied to highlight structure"
}
--- /dev/null
+puts "========"
+puts "OCC27617: Visualization, TKOpenGl - apply highlighting color without disabling lighting"
+puts "========"
+
+pload MODELING VISUALIZATION
+box b 1 2 3
+vclear
+vinit View1
+vdisplay -highMode 1 -dispMode 1 b
+vaxo
+vfit
+vrotate 1 0 0
+vfit
+vmoveto 250 150
+set aColor [vreadpixel 200 150 name rgb]
+if { "$aColor" != "TURQUOISE4" } {
+ puts "Error: Wrong dynamic highlight color"
+}