vtkSMViewProxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
20 #ifndef vtkSMViewProxy_h
21 #define vtkSMViewProxy_h
22 
23 #include "vtkCommand.h" // needed for vtkCommand.
24 #include "vtkRemotingViewsModule.h" //needed for exports
25 #include "vtkSMProxy.h"
26 
27 class vtkImageData;
28 class vtkRenderer;
29 class vtkRenderWindow;
33 class vtkSMSourceProxy;
34 class vtkView;
35 
37 {
38 class WindowToImageFilter;
39 class CaptureHelper;
40 }
41 
43 {
44 public:
45  static vtkSMViewProxy* New();
46  vtkTypeMacro(vtkSMViewProxy, vtkSMProxy);
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
53  vtkSetMacro(Enable, bool);
54  vtkGetMacro(Enable, bool);
55  vtkBooleanMacro(Enable, bool);
57 
61  virtual void StillRender();
62 
66  virtual void InteractiveRender();
67 
71  virtual void Update();
72 
78  virtual bool CanDisplayData(vtkSMSourceProxy* producer, int outputPort);
79 
88  virtual vtkSMRepresentationProxy* CreateDefaultRepresentation(vtkSMProxy*, int);
89 
99  virtual const char* GetRepresentationType(vtkSMSourceProxy* producer, int outputPort);
100 
105  virtual vtkSMRepresentationProxy* FindRepresentation(vtkSMSourceProxy* producer, int outputPort);
106 
108 
113  vtkImageData* CaptureWindow(int magnification)
114  {
115  return this->CaptureWindow(magnification, magnification);
116  }
117  vtkImageData* CaptureWindow(int magnificationX, int magnificationY);
119 
122  vtkView* GetClientSideView();
123 
128  int WriteImage(const char* filename, const char* writerName, int magnification = 1);
129  int WriteImage(
130  const char* filename, const char* writerName, int magnificationX, int magnificationY);
131 
137  virtual bool HasDirtyRepresentation() { return this->GetNeedsUpdate(); }
138 
147  virtual vtkRenderWindow* GetRenderWindow() { return nullptr; }
148 
154  virtual vtkRenderWindowInteractor* GetInteractor() { return nullptr; }
155 
165  virtual void SetupInteractor(vtkRenderWindowInteractor* iren) { (void)iren; }
166 
174  virtual bool MakeRenderWindowInteractor(bool quiet = false);
175 
177 
180  static void SetTransparentBackground(bool val);
181  static bool GetTransparentBackground();
183 
185 
194  virtual bool HideOtherRepresentationsIfNeeded(vtkSMProxy* repr);
196  {
197  return self ? self->HideOtherRepresentationsIfNeeded(repr) : false;
198  }
200 
202 
215  virtual void RepresentationVisibilityChanged(vtkSMProxy* repr, bool new_visibility);
217  vtkSMViewProxy* self, vtkSMProxy* repr, bool new_visibility)
218  {
219  if (self)
220  {
221  self->RepresentationVisibilityChanged(repr, new_visibility);
222  }
223  }
225 
229  static vtkSMViewProxy* FindView(vtkSMProxy* repr, const char* reggroup = "views");
230 
231  enum
232  {
237  PrepareContextForRendering = vtkCommand::UserEvent + 1,
238  };
239 
240 protected:
241  vtkSMViewProxy();
242  ~vtkSMViewProxy() override;
243 
254  virtual vtkImageData* CaptureWindowInternal(int magnificationX, int magnificationY);
255 
260  virtual void RenderForImageCapture() { this->StillRender(); }
261 
272  virtual vtkTypeUInt32 PreRender(bool vtkNotUsed(interactive)) { return this->GetLocation(); }
273 
274  virtual void PostRender(bool vtkNotUsed(interactive)) {}
275 
285  virtual bool IsContextReadyForRendering();
286 
290  void CreateVTKObjects() override;
291 
295  int ReadXMLAttributes(vtkSMSessionProxyManager* pm, vtkPVXMLElement* element) override;
296 
301  bool GetLocalProcessSupportsInteraction();
302 
306  vtkGetObjectMacro(DeliveryManager, vtkSMDataDeliveryManagerProxy);
307 
308  vtkSetStringMacro(DefaultRepresentationName);
310 
311  bool Enable;
312 
313 private:
314  vtkSMViewProxy(const vtkSMViewProxy&) = delete;
315  void operator=(const vtkSMViewProxy&) = delete;
316 
317  bool InRender;
318 
319  vtkSMDataDeliveryManagerProxy* DeliveryManager;
320  static bool TransparentBackground;
321 
322  // Actual logic for taking a screenshot.
323  vtkImageData* CaptureWindowSingle(int magnificationX, int magnificationY);
324 
325  friend class vtkSMViewProxyNS::WindowToImageFilter;
326  friend class vtkSMViewProxyNS::CaptureHelper;
327 };
328 
329 #endif
Proxy for a representations.
vtkImageData * CaptureWindow(int magnification)
Captures a image from this view.
#define VTKREMOTINGVIEWS_EXPORT
virtual void PostRender(bool vtkNotUsed(interactive))
Superclass for all view proxies.
virtual void Update()
char * DefaultRepresentationName
virtual vtkRenderWindow * GetRenderWindow()
Return the vtkRenderWindow used by this view, if any.
virtual vtkRenderWindowInteractor * GetInteractor()
Returns the interactor.
virtual vtkTypeUInt32 PreRender(bool vtkNotUsed(interactive))
This method is called before executing code that could cause a render on the underlying vtkPVView...
virtual void RenderForImageCapture()
This method is called whenever the view wants to render to during image capture.
proxy for a VTK source on a server
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
static bool HideOtherRepresentationsIfNeeded(vtkSMViewProxy *self, vtkSMProxy *repr)
Method used to hide other representations if the view has a <ShowOneRepresentationAtATime/> hint...
virtual bool HasDirtyRepresentation()
Return true any internal representation is dirty.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
server-manager class for vtkPVDataDeliveryManager.
virtual void SetupInteractor(vtkRenderWindowInteractor *iren)
A client process need to set the interactor to enable interactivity.
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
static void RepresentationVisibilityChanged(vtkSMViewProxy *self, vtkSMProxy *repr, bool new_visibility)
Certain views maintain properties (or other state) that should be updated when visibility of represen...