RobotLocomotion / director

A robotics interface and visualization framework, with extensive applications for working with http://drake.mit.edu
BSD 3-Clause "New" or "Revised" License
178 stars 86 forks source link

Allow toggling of antialiasing of rendering #563

Closed gizatt closed 6 years ago

gizatt commented 6 years ago

e.g. as done here in LabelFusion for rendering training images

peteflorence commented 6 years ago

@patmarion hope this one is pretty straightforward, this is just PRing the anti-aliasing feature needed for LabelFusion.

As you may remember, the anti-aliasing has to be set before the GL context is set up, so the only way we could get this to work was inside the cpp constructor.

This PR continues to support the existing Python interface (argument-less)

app = mainwindowapp.construct()

and defaults to using anti-aliasing, but also allows

app = mainwindowapp.construct(disable_anti_alias=True)

Initialization that used to be in the ddQVTKWidgetView constructor has been modularized into the init() function, which is called by the now two different constructor versions

patmarion commented 6 years ago

Looks fine, but, what about using a static cpp variable to globally set rendering options instead of passing the options all the way through the mainwindowapp python code. It seems reasonable to me to apply these settings application wide, rather than per-view as constructor arguments to the ddQVTKWidgetView.

So user code could look like this:

# before constructing the first view, set some rendering options:
import director.visualization as vis
vis.disableAntiAliasing()

# now create the app and view
app = mainwindowapp.construct()

And the implementation of vis.disableAntiAliasing() would look like:

def disableAntiAliasing:
  PythonQt.dd.ddQVTKWidgetView.setAntiAliasing(False)

And then create a static cpp function:

class ddQVTKWidget {
...

  static void setAntiAliasing(bool enabled);
};

And in the cpp:

namespace {
  antiAliasingEnabled = True
};

void ddQVTKWidgetView::setAntiAliasing(bool enabled)
{
  antiAliasingEnabeld = enabled
}
patmarion commented 6 years ago

Also, style fix:

instead of disable_anti_aliasing please us disableAntiAliasing to be consistent with the current style

peteflorence commented 6 years ago

Pat good idea, that is cleaner. Not sure when can get to it but I can try out implementing that way

manuelli commented 6 years ago

Superseded by #611.