------------------------------------------------------------------------------ Initializes the event handlers without an XtAppContext. This is good for when you don't have a user interface, but you still want to have mouse interaction.
| 370 | // good for when you don't have a user interface, but you still |
| 371 | // want to have mouse interaction. |
| 372 | void vtkXRenderWindowInteractor::Initialize() |
| 373 | { |
| 374 | if (this->Initialized) |
| 375 | { |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | vtkRenderWindow* ren; |
| 380 | int* size; |
| 381 | |
| 382 | // make sure we have a RenderWindow and camera |
| 383 | if (!this->RenderWindow) |
| 384 | { |
| 385 | vtkErrorMacro(<< "No renderer defined!"); |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | this->Initialized = 1; |
| 390 | ren = this->RenderWindow; |
| 391 | |
| 392 | ren->EnsureDisplay(); |
| 393 | this->DisplayId = static_cast<Display*>(ren->GetGenericDisplayId()); |
| 394 | |
| 395 | vtkXRenderWindowInteractorInternals::Instances.insert(this); |
| 396 | |
| 397 | size = ren->GetActualSize(); |
| 398 | size[0] = ((size[0] > 0) ? size[0] : 300); |
| 399 | size[1] = ((size[1] > 0) ? size[1] : 300); |
| 400 | if (this->DisplayId) |
| 401 | { |
| 402 | this->Internal->DisplayConnection = ConnectionNumber(this->DisplayId); |
| 403 | vtkXSync(this->DisplayId, False); |
| 404 | } |
| 405 | |
| 406 | ren->Start(); |
| 407 | ren->End(); |
| 408 | |
| 409 | this->WindowId = reinterpret_cast<Window>(ren->GetGenericWindowId()); |
| 410 | |
| 411 | if (this->DisplayId && this->WindowId) |
| 412 | { |
| 413 | XWindowAttributes attribs; |
| 414 | // Find the current window size |
| 415 | auto* previousHandler = vtkXSetErrorHandler([](Display*, XErrorEvent*) { return 0; }); |
| 416 | if (vtkXGetWindowAttributes(this->DisplayId, this->WindowId, &attribs)) |
| 417 | { |
| 418 | size[0] = attribs.width; |
| 419 | size[1] = attribs.height; |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | // window does not exist. `ren` is not an X11 render window. |
| 424 | this->WindowId = 0; |
| 425 | } |
| 426 | vtkXSetErrorHandler(previousHandler); |
| 427 | } |
| 428 | ren->SetSize(size[0], size[1]); |
| 429 |
nothing calls this directly
no test coverage detected