6.5.0 Visualization Highlights. Part1

by - 22:41

Open CASCADE 6.5.0 has introduced a few nice (undocumented, as often) features in its Visualization module and I'm going to highlight a couple of them today. Even if the version 6.5.0 made some mixed impressions (with regressions in BRepMesh being most unpleasant ones), visualization was really nice. So kudos to the involved folks!

When migrating CAD Exchanger to 6.5.0 I wanted to rework the way a gradient background is displayed. The previous way was described in the old blog post. 6.5.0 has added a 'built-in' support for gradients offering various options (horizontal, vertical, diagonal, corners, etc). Below is a sample screenshot made in DRAW:


Built-in gradient background support in 6.5.0 (using diagonal1 option).

You might want to experiment more using the vsetgradientbg command. The new API can be used as simply as follows:

Handle(V3d_View) myView = ...;
if (theEnable) {
myView->SetBgGradientColors (myTopBackgroundColor, myBottomBackgroundColor, Aspect_GFM_HOR, Standard_False);
} else {
myView->SetBgGradientColors (myTopBackgroundColor, myBottomBackgroundColor, Aspect_GFM_NONE, Standard_False);
}

You May Also Like

3 comments

  1. Thanks for sharing this, Roman. Is the gradient implemented by drawing a polygon with window corners obtained with gluUnproject and with vertex colors? Tried to ding into the code but it is delegated too much to many subroutine calls. I got stuck at the call_subr_set_gradient_background function.

    ReplyDelete
  2. Hi Sharjit,
    I don't remember if I had traced this down but I remember that was quite straightforward if to attach with a debugger to vsetgradientbg command in DRAW. Looking at the source code it is obvious that setting background is now part of TsmGetWSAttri() (see OpenGl_ws.cxx). Not sure where the set data is used though.
    Prior to 6.5.0 I used Visual3d_Layer::SetColor() and ::AddVertex() to draw a rectangle.

    ReplyDelete
  3. Yes Roman, the TsmGetWSAttri is what gets called pretty much for all the low level OpenGL settings. But I wonder what is the easy way to walk through. I should try debugging DRAW as you suggested. The approach of using AddVertex that I had tried earlier from your blog has some issues though. The gradient polygon disappears when the objects are hilighted in a local context opened. That hopefully doesn't happen with the feature built-in now, I haven't tried it yet.

    ReplyDelete