[vtk-developers] Slow resize of vtkContextView (on Win 10)

Elvis Stansvik elvis.stansvik at orexplore.com
Sat Aug 25 07:03:33 EDT 2018


I don't think the code matters much, but here it is (it was the
beginning of a test case for something else, so has some unrelated
things in it):

#include <QApplication>
#include <QSurfaceFormat>
#include <QDebug>

#include <QVTKOpenGLWidget.h>

#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkSmartPointer.h>
#include <vtkChartXY.h>
#include <vtkContextView.h>
#include <vtkContextScene.h>
#include <vtkTextProperty.h>
#include <vtkFreeTypeTools.h>
#include <vtkAxis.h>

int main(int argc, char *argv[])
{
    vtkFreeTypeTools::GetInstance()->ForceCompiledFontsOff();

    QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());

    QApplication app(argc, argv);

    auto window = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();

    auto widget = new QVTKOpenGLWidget();
    widget->SetRenderWindow(window);
    qDebug() << "Setting DPI to" << widget->logicalDpiX();
    window->SetDPI(widget->logicalDpiX());

    auto chart = vtkSmartPointer<vtkChartXY>::New();
    chart->AddPlot(vtkChart::LINE);
    chart->GetAxis(vtkAxis::BOTTOM)->SetVisible(false);

    for (auto axisId : { vtkAxis::LEFT, vtkAxis::BOTTOM }) {
        auto axis = chart->GetAxis(axisId);

        auto labelProperty = axis->GetLabelProperties();
        labelProperty->SetFontFamilyAsString("Tahoma");
        labelProperty->SetFontSize(8);

        auto titleProperty = axis->GetTitleProperties();
        titleProperty->SetFontFamilyAsString("Tahoma");
        titleProperty->SetFontSize(8);
    }

    auto view = vtkSmartPointer<vtkContextView>::New();
    view->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
    view->SetRenderWindow(window.Get());
    view->GetScene()->AddItem(chart);

    widget->show();

    return app.exec();
}

Elvis

2018-08-25 13:01 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> Hi all,
>
> As I was debugging DPI issues on Windows today, I noticed an unrelated thing.
>
> Resizing a vtkContextView (in this case, containing a vtkChartXY) is
> very (!) slow.
>
> See the following screen recording where I resize the window:
>
>     https://drive.google.com/open?id=1pOKuDjT4IwE54xIRQoYni5-A2PUeZtbL
>
> The recording itself makes it look a little worse than it is, but it's
> not far off from the actual experience.
>
> This was on Win 10, with VTK 8.1.1, OpenGL 2 backend, Qt 5.11.1. The
> vtkContextView was in a QVTKOpenGLWidget.
>
> I know that accomplishing smooth resizing of GL windows is
> non-trivial, but should it really be this bad? It makes it impossible
> to build Qt/VTK applications that resize smoothly.
>
> Best regards,
> Elvis


More information about the vtk-developers mailing list