Hello,<div><br></div><div>I'm working on porting an application made from a mixture of VTK 5.4 and wxWidgets to VTK 5.11 and Qt 4.8. I have multiple (up to 4) QVTKWidget2s on the screen to display the same data from different viewpoints. Each widget has its own mapper and actor objects, but the mappers all share the same polydata source. It works well until I modify the polydata source and mark it with source->Modified(). This makes each QVTKWidget2 take a long time to render the first time, and then they all work smoothly again. I assume they're rebuilding display lists or something. Is there any way to improve this performance? Below is an example application that demonstrates the issue. Press the space key to modify the sphereSource object and then subsequent interactions with the QVTKWidget2 objects will be slow for the first render. Perhaps I'm not creating multiple views correctly. Thank you ahead of time for the help!</div>
<div><br></div><div>Thanks,</div><div>Doug</div><div><br></div><div><div><br></div><div><div>SlowQVTKWidget2::SlowQVTKWidget2(QWidget *parent, Qt::WFlags flags)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>: QMainWindow(parent, flags)</div>
<div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>QSplitter *splitter = new QSplitter(this);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>QVTKWidget2 *w1 = new QVTKWidget2();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>QVTKWidget2 *w2 = new QVTKWidget2();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>splitter->addWidget(w1);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>splitter->addWidget(w2);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Create sphereSource which is shared by the vtkPolyDataMappers for both QVTKWidgets</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource = vtkSmartPointer<vtkSphereSource>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->SetPhiResolution(500);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->SetThetaResolution(500);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereSource->Update();</div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>// Create the sphereMapper for the left QVTKWidget, set its source to the sphereSource</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Also create an actor for the left QVTKWidget</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyDataMapper> sphereMapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereMapper->SetInputConnection(sphereSource->GetOutputPort());</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereActor->SetMapper(sphereMapper);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereMapper->Update();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// sphereMapper2 Uses the same sphereSource as sphereMapper</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>// Also, create sphereActor2 which uses sphereMapper2</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyDataMapper> sphereMapper2 =vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereMapper2->SetInputConnection(sphereSource->GetOutputPort());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkActor> sphereActor2 = vtkSmartPointer<vtkActor>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereActor2->SetMapper(sphereMapper2);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sphereMapper2->Update();</div><div> </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>// cube1</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkCubeSource> cubeSource = vtkSmartPointer<vtkCubeSource>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeSource->Update();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyDataMapper> cubeMapper =<span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeMapper->SetInputConnection(cubeSource->GetOutputPort());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkActor> cubeActor = vtkSmartPointer<vtkActor>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeActor->SetMapper(cubeMapper);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// cube2</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyDataMapper> cubeMapper2 = vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeMapper2->SetInputConnection(cubeSource->GetOutputPort());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkActor> cubeActor2 = vtkSmartPointer<vtkActor>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeActor2->SetMapper(cubeMapper2);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// VTK Renderer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderer> leftRenderer = vtkSmartPointer<vtkRenderer>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderer> rightRenderer = vtkSmartPointer<vtkRenderer>::New();</div><div> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeActor->SetPosition(0,2,0);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>cubeActor2->SetPosition(0,2,0);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Add both actors to each renderer</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>leftRenderer->AddActor(cubeActor);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>leftRenderer->AddActor(sphereActor);</div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>rightRenderer->AddActor(cubeActor2);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rightRenderer->AddActor(sphereActor2);</div><div>
</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// VTK/Qt wedded</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>w1->GetRenderWindow()->AddRenderer(leftRenderer);</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>w2->GetRenderWindow()->AddRenderer(rightRenderer);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>this->resize(800,600);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>this->setCentralWidget(splitter);</div><div>}</div><div><br></div><div><br></div><div>void SlowQVTKWidget2::keyPressEvent(QKeyEvent *event){</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// When spacebar is pressed, we adjust sphereSource's data and mark it as modified.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// This causes a slow down when the user manipulates the QVTKWidgets.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>if(event->key() == 32)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>this->sphereSource->SetThetaResolution(600);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>this->sphereSource->Modified();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div></div><div><br></div>
<div><br></div>