Skip to content

Commit

Permalink
allow toggling of anti aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelli committed Jul 31, 2018
1 parent a5a6f6f commit 4460ac6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/ddQVTKWidgetView.cpp
Expand Up @@ -53,6 +53,7 @@ class vtkCustomRubberBandStyle : public vtkInteractorStyleRubberBand3D

vtkStandardNewMacro(vtkCustomRubberBandStyle);

bool ddQVTKWidgetView::antiAliasingEnabled = true;

//-----------------------------------------------------------------------------
class ddQVTKWidgetView::ddInternal
Expand Down Expand Up @@ -110,7 +111,13 @@ ddQVTKWidgetView::ddQVTKWidgetView(QWidget* parent) : ddViewBase(parent)
this->Internal->VTKWidget->SetRenderWindow(this->Internal->RenderWindow);
#endif
this->Internal->VTKWidget->SetRenderWindow(this->Internal->RenderWindow);
this->Internal->RenderWindow->SetMultiSamples(8);

if (antiAliasingEnabled){
this->Internal->RenderWindow->SetMultiSamples(8);
} else {
this->Internal->RenderWindow->SetMultiSamples(0);
}

this->Internal->RenderWindow->StereoCapableWindowOn();
this->Internal->RenderWindow->SetStereoTypeToRedBlue();
this->Internal->RenderWindow->StereoRenderOff();
Expand Down Expand Up @@ -255,6 +262,12 @@ double ddQVTKWidgetView::getAverageFramesPerSecond()
return this->Internal->FPSCounter.averageFPS();
}

//-----------------------------------------------------------------------------
void ddQVTKWidgetView::setAntiAliasing(bool enabled)
{
antiAliasingEnabled = enabled;
}

//-----------------------------------------------------------------------------
void ddQVTKWidgetView::addCustomBounds(const QList<double>& bounds)
{
Expand Down
4 changes: 4 additions & 0 deletions src/app/ddQVTKWidgetView.h
Expand Up @@ -42,6 +42,8 @@ class DD_APP_EXPORT ddQVTKWidgetView : public ddViewBase

double getAverageFramesPerSecond();

static void setAntiAliasing(bool enabled);

signals:

void computeBoundsRequest(ddQVTKWidgetView* view);
Expand Down Expand Up @@ -70,6 +72,8 @@ protected slots:
class ddInternal;
ddInternal* Internal;

static bool antiAliasingEnabled;

Q_DISABLE_COPY(ddQVTKWidgetView);
};

Expand Down
1 change: 1 addition & 0 deletions src/app/wrapped_methods.txt
Expand Up @@ -5,6 +5,7 @@ ddQVTKWidgetView::ddQVTKWidgetView();
ddQVTKWidgetView::~ddQVTKWidgetView();
vtkCamera* ddQVTKWidgetView::camera() const;
double ddQVTKWidgetView::getAverageFramesPerSecond();
static void ddQVTKWidgetView::setAntiAliasing(bool);
vtkRenderWindow* ddQVTKWidgetView::renderWindow() const;
vtkRenderer* ddQVTKWidgetView::renderer() const;
vtkRenderer* ddQVTKWidgetView::backgroundRenderer() const;
Expand Down
12 changes: 12 additions & 0 deletions src/python/director/visualization.py
Expand Up @@ -8,6 +8,7 @@
from director import frameupdater
from director.fieldcontainer import FieldContainer
from PythonQt import QtCore, QtGui
import PythonQt
import numpy as np
import os
import colorsys
Expand Down Expand Up @@ -1213,6 +1214,17 @@ def findPickedObject(displayPoint, view):
obj = getObjectByProp(pickedProp)
return obj, pickedPoint

"""
Toggles whether anti-aliasing is enabled or not.
This sets a static variable in the ddQVTKWidgeView
so this controls the setting for all views created in the current
executable. Must be called before constructing a ddQTKWidgetView
Anti-aliasing is enabled by default
"""
def setAntiAliasing(enabled):
PythonQt.dd.ddQVTKWidgetView.setAntiAliasing(enabled)


def enableEyeDomeLighting(view):

Expand Down

0 comments on commit 4460ac6

Please sign in to comment.