简体   繁体   中英

QT, VTK project on linux not running

I am trying to launch a ITK/VTQ project with Qt. The project runs on Windows 10, but not on Ubuntu.

I have the following error during launching the project:

X Error: BadColor (invalid Colormap parameter) 12
  Major opcode: 1 (X_CreateWindow)
  Resource id:  0x4a00001
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 3 (X_GetWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 7 (X_ReparentWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 10 (X_UnmapWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 12 (X_ConfigureWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 8 (X_MapWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 8 (X_MapWindow)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x480001a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 3 (X_GetWindowAttributes)
  Resource id:  0x480001a
Erreur de segmentation (core dumped)

Here is my code :

void ImageViewerWidget::InitRender()
{

/*** INITIALIZATION ***/

// init the actor
m_texturedQuad = vtkSmartPointer<vtkActor>::New();
_openGLproperty = static_cast<vtkOpenGLProperty*>(m_texturedQuad->GetProperty());

// init the quad
_quadPolyData = vtkSmartPointer<vtkPolyData>::New();


// create the texture object
_textureCoordinates = vtkSmartPointer<vtkFloatArray>::New();
_textureCoordinates->SetNumberOfComponents(3);
_textureCoordinates->SetName("TextureCoordinates");

float tuple[3] = {0.0, 0.0, 0.0};
_textureCoordinates->InsertNextTuple(tuple);
tuple[0] = 1.0; tuple[1] = 0.0; tuple[2] = 0.0;
_textureCoordinates->InsertNextTuple(tuple);
tuple[0] = 1.0; tuple[1] = 1.0; tuple[2] = 0.0;
_textureCoordinates->InsertNextTuple(tuple);
tuple[0] = 0.0; tuple[1] = 1.0; tuple[2] = 0.0;
_textureCoordinates->InsertNextTuple(tuple);


// create the itk/vtk converter
m_itkToVtkConverter = itk::ImageToVTKImageFilter<itk::Image<float, 3> >::New();


/*** Init the Renderer ***/
m_imageRenderer = vtkSmartPointer<vtkRenderer>::New();
m_imageRenderer->SetBackground(1,1,1); // Background color white
m_imageRenderer->ResetCamera();


/*** Init the Render Window ***/
m_imageRenderWindow = vtkSmartPointer<vtkRenderWindow>::New();
m_imageRenderWindow->AddRenderer(m_imageRenderer);


/*** Init the Shader ***/
SetActiveShader("BasicShader");


/*** Set Render Window to viewer ***/
// FIXME: the software crashes here on GNU/Linux
viewer->SetRenderWindow(m_imageRenderWindow);

}

I found that the problem is here :

viewer->SetRenderWindow(m_imageRenderWindow);

How I can correct this error message ?

Where is the problem ?

A big chunk of your code ( _textureCoordinates and stuff above) is not connected to the rest. And what you have shown here is not a runnable example, but it looks like you are not properly setting up VTK (compare with VTK hello world ).

Have you tried looking at some of the examples on VTK wiki? Also, why don't you start with a working VTK/QT example and gradually extend it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM