@sankhesh these are the errors that appear on stderr as I’m dragging the mouse, i.e. not a stack trace:
0x7f98511cfd07 : QQuickVTKItem::updatePaintNode(QSGNode*, QQuickItem::UpdatePaintNodeData*) [(libvtkGUISupportQtQuick-9.3.so.1) ???:-1]
0x7f984d3338b8 : QQuickWindowPrivate::updateDirtyNode(QQuickItem*) [(libQt6Quick.so.6) ???:-1]
0x7f984d334234 : QQuickWindowPrivate::updateDirtyNodes() [(libQt6Quick.so.6) ???:-1]
0x7f984d33825e : QQuickWindowPrivate::syncSceneGraph() [(libQt6Quick.so.6) ???:-1]
But here is an interesting development. I provided claude.ai with the information provided in this post, and it responded with several possible solutions, one of which ‘fixed’ those errors, i.e. they no longer appear on stderr while dragging the mouse. The solution was this:
/* **** Recommended by Claude.ai *** */
vtkOpenGLRenderWindow* renWin =
vtkOpenGLRenderWindow::SafeDownCast(this->Interactor->GetRenderWindow());
vtkOpenGLState* ostate;
if (renWin) {
std::cerr << "got renWin\n";
ostate = renWin->GetState();
// Push current state
ostate->Push();
}
/* ******************************* */
std::cerr << "RedrawRubberBand(): set rgb pixel data\n";
this->Interactor->
GetRenderWindow()->SetRGBACharPixelData(
0, 0, size[0] - 1, size[1] - 1,
pixels, 0);
std::cerr << "RedrawRubberBand(): get render window frame\n";
this->Interactor->GetRenderWindow()->Frame();
std::cerr << "RedrawRubberBand(): delete tmpPixelArray\n";
tmpPixelArray->Delete();
std::cerr << "RedrawRubberBand(): tmpPixelArray DELETED\n";
/* **** Recommended by Claude.ai *** */
if (renWin) {
// Pop back to previous state
ostate->Pop();
}
/* ******************************* */
So I don’t see error messages on mouse drag - but also do not see a red box tracking the area selected by the mouse. I.e. the call to SetRGBACharPixelData() doesn’t result in a red box. I do see a red box when using MyRubberBandStyle with a VTK-only application (i.e. no integration with Qt). Why might this be so? Here is the complete source for MyRubberBandStyle::RedrawRubberBand():
//------------------------------------------------------------------------------
void MyRubberBandStyle::RedrawRubberBand()
{
std::cerr << "MyRubberBandStyle::RedrawRubberBand() thread: " <<
std::this_thread::get_id() << "\n";
// update the rubber band on the screen
const int* size = this->Interactor->GetRenderWindow()->GetSize();
vtkUnsignedCharArray* tmpPixelArray = vtkUnsignedCharArray::New();
tmpPixelArray->DeepCopy(this->PixelArray);
unsigned char* pixels = tmpPixelArray->GetPointer(0);
int min[2], max[2];
min[0] =
this->StartPosition[0] <= this->EndPosition[0] ? this->StartPosition[0] : this->EndPosition[0];
if (min[0] < 0)
{
min[0] = 0;
}
if (min[0] >= size[0])
{
min[0] = size[0] - 1;
}
min[1] =
this->StartPosition[1] <= this->EndPosition[1] ? this->StartPosition[1] : this->EndPosition[1];
if (min[1] < 0)
{
min[1] = 0;
}
if (min[1] >= size[1])
{
min[1] = size[1] - 1;
}
max[0] =
this->EndPosition[0] > this->StartPosition[0] ? this->EndPosition[0] : this->StartPosition[0];
if (max[0] < 0)
{
max[0] = 0;
}
if (max[0] >= size[0])
{
max[0] = size[0] - 1;
}
max[1] =
this->EndPosition[1] > this->StartPosition[1] ? this->EndPosition[1] : this->StartPosition[1];
if (max[1] < 0)
{
max[1] = 0;
}
if (max[1] >= size[1])
{
max[1] = size[1] - 1;
}
int i;
for (i = min[0]; i <= max[0]; i++)
{
pixels[4 * (min[1] * size[0] + i)] = 255 ^ pixels[4 * (min[1] * size[0] + i)];
pixels[4 * (min[1] * size[0] + i) + 1] = 255 ^ pixels[4 * (min[1] * size[0] + i) + 1];
pixels[4 * (min[1] * size[0] + i) + 2] = 255 ^ pixels[4 * (min[1] * size[0] + i) + 2];
pixels[4 * (max[1] * size[0] + i)] = 255 ^ pixels[4 * (max[1] * size[0] + i)];
pixels[4 * (max[1] * size[0] + i) + 1] = 255 ^ pixels[4 * (max[1] * size[0] + i) + 1];
pixels[4 * (max[1] * size[0] + i) + 2] = 255 ^ pixels[4 * (max[1] * size[0] + i) + 2];
}
for (i = min[1] + 1; i < max[1]; i++)
{
pixels[4 * (i * size[0] + min[0])] = 255 ^ pixels[4 * (i * size[0] + min[0])];
pixels[4 * (i * size[0] + min[0]) + 1] = 255 ^ pixels[4 * (i * size[0] + min[0]) + 1];
pixels[4 * (i * size[0] + min[0]) + 2] = 255 ^ pixels[4 * (i * size[0] + min[0]) + 2];
pixels[4 * (i * size[0] + max[0])] = 255 ^ pixels[4 * (i * size[0] + max[0])];
pixels[4 * (i * size[0] + max[0]) + 1] = 255 ^ pixels[4 * (i * size[0] + max[0]) + 1];
pixels[4 * (i * size[0] + max[0]) + 2] = 255 ^ pixels[4 * (i * size[0] + max[0]) + 2];
}
/* **** Recommended by Claude.ai *** */
vtkOpenGLRenderWindow* renWin =
vtkOpenGLRenderWindow::SafeDownCast(this->Interactor->GetRenderWindow());
vtkOpenGLState* ostate;
if (renWin) {
std::cerr << "got renWin\n";
ostate = renWin->GetState();
// Push current state
ostate->Push();
}
/* ******************************* */
std::cerr << "RedrawRubberBand(): set rgb pixel data\n";
this->Interactor->
GetRenderWindow()->SetRGBACharPixelData(
0, 0, size[0] - 1, size[1] - 1,
pixels, 0);
std::cerr << "RedrawRubberBand(): get render window frame\n";
this->Interactor->GetRenderWindow()->Frame();
std::cerr << "RedrawRubberBand(): delete tmpPixelArray\n";
tmpPixelArray->Delete();
std::cerr << "RedrawRubberBand(): tmpPixelArray DELETED\n";
/* **** Recommended by Claude.ai *** */
if (renWin) {
// Pop back to previous state
ostate->Pop();
}
/* ******************************* */
std::cerr << "Leave MyRubberBandStyle::RedrawRubberBand()\n";
}