Point Cloud Library (PCL)  1.14.1-dev
viewport.h
1 #pragma once
2 
3 // C++
4 #include <iostream>
5 #include <string>
6 
7 // PCL
8 #include "camera.h"
9 
10 // VTK
11 #include <vtkActor.h>
12 #include <vtkCallbackCommand.h>
13 #include <vtkObject.h>
14 #include <vtkTextActor.h>
15 #include <vtkRenderer.h>
16 #include <vtkRenderWindow.h>
17 #include <vtkSmartPointer.h>
18 
19 class Viewport
20 {
21 public:
22 
23  // Operators
24  // -----------------------------------------------------------------------------
25  Viewport (vtkSmartPointer<vtkRenderWindow> window, double xmin = 0.0, double ymin = 0.0, double xmax = 1.0,
26  double ymax = 1.0);
27 
28  // Accessors
29  // -----------------------------------------------------------------------------
31  getRenderer () const
32  {
33  return renderer_;
34  }
35 
36  void
37  setCamera (Camera* camera)
38  {
39  renderer_->SetActiveCamera (vtkCamera::SafeDownCast (camera->getCamera ()));
40  camera_hud_actor_->SetInput (camera->getName ().c_str ());
41  renderer_->ResetCamera ();
42  }
43 
44 private:
45 
46  // Callbacks
47  // -----------------------------------------------------------------------------
48  static void
49  viewportModifiedCallback (vtkObject* caller, unsigned long int vtkNotUsed(eventId), void* vtkNotUsed(clientData),
50  void* vtkNotUsed(callData));
51 
52  void
53  viewportModified ();
54 
55  static void
56  viewportActorUpdateCallback (vtkObject* caller, unsigned long int vtkNotUsed(eventId), void* vtkNotUsed(clientData),
57  void* vtkNotUsed(callData));
58 
59  void
60  viewportActorUpdate ();
61 
62  static void
63  viewportHudUpdateCallback (vtkObject* caller, unsigned long int vtkNotUsed(eventId), void* vtkNotUsed(clientData),
64  void* vtkNotUsed(callData));
65 
66  void
67  viewportHudUpdate ();
68 
69  // Members
70  // -----------------------------------------------------------------------------
72  vtkSmartPointer<vtkCallbackCommand> viewport_modified_callback_;
73  vtkSmartPointer<vtkCallbackCommand> viewport_actor_update_callback_;
74  vtkSmartPointer<vtkCallbackCommand> viewport_hud_callback_;
75 
76  vtkSmartPointer<vtkTextActor> camera_hud_actor_;
77  vtkSmartPointer<vtkTextActor> fps_hud_actor_;
78  vtkSmartPointer<vtkTextActor> points_hud_actor_;
79 };
Definition: camera.h:21
vtkSmartPointer< vtkCamera > getCamera() const
Definition: camera.h:37
std::string getName() const
void setCamera(Camera *camera)
Definition: viewport.h:37
vtkSmartPointer< vtkRenderer > getRenderer() const
Definition: viewport.h:31
Viewport(vtkSmartPointer< vtkRenderWindow > window, double xmin=0.0, double ymin=0.0, double xmax=1.0, double ymax=1.0)