MCPcopy Create free account
hub / github.com/Kitware/VTK / Initialize

Method Initialize

Rendering/UI/vtkXRenderWindowInteractor.cxx:372–433  ·  view source on GitHub ↗

------------------------------------------------------------------------------ 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.

Source from the content-addressed store, hash-verified

370// good for when you don't have a user interface, but you still
371// want to have mouse interaction.
372void 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

Callers

nothing calls this directly

Calls 9

EnableMethod · 0.95
GetActualSizeMethod · 0.80
EnsureDisplayMethod · 0.45
GetGenericDisplayIdMethod · 0.45
insertMethod · 0.45
StartMethod · 0.45
EndMethod · 0.45
GetGenericWindowIdMethod · 0.45
SetSizeMethod · 0.45

Tested by

no test coverage detected