Hi,
I attach two animated gif files:
- first demonstrates how slow vtkCubeAxesActor interaction works;
- second shows how fast works cylinder example
Even in gif animation you can notice that cube axes extremelly decreases the perfomance.
By the way even my laptop is old enough (see setup at the end of this post) it works with 500 MegaBytes vtkImageData
without problems.
I use the code below to generate cube axes example (raw vtk cube axes example gives the same result, so don’t pay attention on some excessive lines inside the code). I also use Qt but there is no matter whether I create renderer window on QWidget or I use native rendering window.
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
//VTK_MODULE_INIT(vtkRenderingContextOpenGL2); // this is for 2D graphics [link](http://vtk.1045678.n5.nabble.com/Error-no-override-found-for-vtkContextDevice2D-td5741533.html)
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
#include "mpi.h"
#include "MainWindow.h"
#include <QApplication>
#include <QSurfaceFormat>
#include <QVTKOpenGLNativeWidget.h>
#include <QVTKOpenGLNativeWidget.h>
#include <vtkActor.h>
#include <vtkActorCollection.h>
#include <vtkCamera.h>
#include <vtkColor.h>
#include <vtkCubeAxesActor.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSuperquadricSource.h>
#include <vtkTextProperty.h>
#include <vtkTransform.h>
#include <vtkTextActor.h>
#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2,vtkInteractionStyle,vtkRenderingFreeType)
#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL2)
int main(int argc, char *argv[]) {
// Define colors for this example
vtkNew<vtkNamedColors> colors;
vtkColor3d backgroundColor = colors->GetColor3d("DarkSlateGray");
vtkColor3d actorColor = colors->GetColor3d("Tomato");
vtkColor3d axis1Color = colors->GetColor3d("Salmon");
vtkColor3d axis2Color = colors->GetColor3d("PaleGreen");
vtkColor3d axis3Color = colors->GetColor3d("LightSkyBlue");
// Create a superquadric
vtkNew<vtkSuperquadricSource> superquadricSource;
superquadricSource->SetPhiRoundness(3.1);
superquadricSource->SetThetaRoundness(1.0);
superquadricSource->Update(); // needed to GetBounds later
vtkNew<vtkRenderer> renderer;
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(superquadricSource->GetOutputPort());
vtkNew<vtkActor> superquadricActor;
superquadricActor->SetMapper(mapper);
superquadricActor->GetProperty()->SetDiffuseColor(actorColor.GetData());
superquadricActor->GetProperty()->SetDiffuse(.7);
superquadricActor->GetProperty()->SetSpecular(.7);
superquadricActor->GetProperty()->SetSpecularPower(50.0);
vtkNew<vtkCubeAxesActor> cubeAxesActor;
cubeAxesActor->SetUseTextActor3D(1);
cubeAxesActor->SetBounds(superquadricSource->GetOutput()->GetBounds());
cubeAxesActor->SetCamera(renderer->GetActiveCamera());
cubeAxesActor->GetTitleTextProperty(0)->SetColor(axis1Color.GetData());
// cubeAxesActor->GetTitleTextProperty(0)->SetFontSize(48);
cubeAxesActor->GetLabelTextProperty(0)->SetColor(axis1Color.GetData());
cubeAxesActor->GetTitleTextProperty(1)->SetColor(axis2Color.GetData());
cubeAxesActor->GetLabelTextProperty(1)->SetColor(axis2Color.GetData());
cubeAxesActor->GetTitleTextProperty(2)->SetColor(axis3Color.GetData());
cubeAxesActor->GetLabelTextProperty(2)->SetColor(axis3Color.GetData());
cubeAxesActor->DrawXGridlinesOn();
cubeAxesActor->DrawYGridlinesOn();
cubeAxesActor->DrawZGridlinesOn();
#if VTK_MAJOR_VERSION == 6
cubeAxesActor->SetGridLineLocation(VTK_GRID_LINES_FURTHEST);
#endif
#if VTK_MAJOR_VERSION > 6
cubeAxesActor->SetGridLineLocation(cubeAxesActor->VTK_GRID_LINES_FURTHEST);
#endif
cubeAxesActor->XAxisMinorTickVisibilityOff();
cubeAxesActor->YAxisMinorTickVisibilityOff();
cubeAxesActor->ZAxisMinorTickVisibilityOff();
cubeAxesActor->SetFlyModeToStaticEdges();
cubeAxesActor->SetUse2DMode(1); // this solves the problem for scaling text
// Setup the text and add it to the renderer
vtkNew<vtkTextActor> textActor;
textActor->SetInput("Hello world");
textActor->SetPosition2(10, 40);
textActor->GetTextProperty()->SetFontSize(24);
textActor->GetTextProperty()->SetColor(colors->GetColor3d("Gold").GetData());
renderer->AddActor(cubeAxesActor);
renderer->AddActor(superquadricActor);
renderer->AddActor(textActor);
renderer->GetActiveCamera()->Azimuth(30);
renderer->GetActiveCamera()->Elevation(30);
renderer->ResetCamera();
renderer->SetBackground(backgroundColor.GetData());
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->SetSize(640, 480);
renderWindow->SetWindowName("CubeAxesActor");
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindow->Render();
renderer->GetActiveCamera()->Zoom(0.8);
vtkNew<vtkTransform> transform;
// transform->Scale(10, 1, 1);
renderer->GetActiveCamera()->SetModelTransformMatrix(transform->GetMatrix());
renderWindowInteractor->Start();
return 0;
}
My setup:
Windows 10, VTK 9.0.1, MSVC 2017 x64, quite old laptop from 2011 year (but that should not be a reason why FPS goes down from 20-24 to 1), 2 physical cores, 2 logical cores, 8 GB RAM, NVIDIA Ge GForce GT 520M (as you may already know laptops usually have 2 videocards thus I manually set to use more powerful Nvidia card to launch the app instead of native Intel)
I also tested the same thing on Ubuntu 20.04 with GCC 9.3 on more powerful stationary PC with 4 cores (4 physical and 4 logical), 20 GB RAM, VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
ALL TESTS WERE MADE IN DEBUG MODE (I only have compiled VTK in debug mode)