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 
42 class VTKREMOTINGVIEWS_EXPORT vtkSMViewProxy : public vtkSMProxy
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 
77  void ThreadedUpdate(bool threaded);
78 
84  virtual bool CanDisplayData(vtkSMSourceProxy* producer, int outputPort);
85 
94  virtual vtkSMRepresentationProxy* CreateDefaultRepresentation(vtkSMProxy*, int);
95 
105  virtual const char* GetRepresentationType(vtkSMSourceProxy* producer, int outputPort);
106 
111  virtual vtkSMRepresentationProxy* FindRepresentation(vtkSMSourceProxy* producer, int outputPort);
112 
114 
122  vtkImageData* CaptureWindow(int magnification)
123  {
124  return this->CaptureWindow(magnification, magnification);
125  }
127  vtkImageData* CaptureWindow(int magnificationX, int magnificationY);
129 
132  vtkView* GetClientSideView();
133 
138  int WriteImage(const char* filename, const char* writerName, int magnification = 1);
139  int WriteImage(
140  const char* filename, const char* writerName, int magnificationX, int magnificationY);
141 
147  virtual bool HasDirtyRepresentation() { return this->GetNeedsUpdate(); }
148 
157  virtual vtkRenderWindow* GetRenderWindow() { return nullptr; }
158 
164  virtual vtkRenderWindowInteractor* GetInteractor() { return nullptr; }
165 
175  virtual void SetupInteractor(vtkRenderWindowInteractor* iren) { (void)iren; }
176 
184  virtual bool MakeRenderWindowInteractor(bool quiet = false);
185 
187 
190  static void SetTransparentBackground(bool val);
191  static bool GetTransparentBackground();
193 
195 
204  virtual bool HideOtherRepresentationsIfNeeded(vtkSMProxy* repr);
206  {
207  return self ? self->HideOtherRepresentationsIfNeeded(repr) : false;
208  }
210 
212 
225  virtual void RepresentationVisibilityChanged(vtkSMProxy* repr, bool new_visibility);
227  vtkSMViewProxy* self, vtkSMProxy* repr, bool new_visibility)
228  {
229  if (self)
230  {
231  self->RepresentationVisibilityChanged(repr, new_visibility);
232  }
233  }
235 
239  static vtkSMViewProxy* FindView(vtkSMProxy* repr, const char* reggroup = "views");
240 
241  enum
242  {
247  PrepareContextForRendering = vtkCommand::UserEvent + 1,
248  };
249 
250 protected:
251  vtkSMViewProxy();
252  ~vtkSMViewProxy() override;
253 
264  virtual vtkImageData* CaptureWindowInternal(int magnificationX, int magnificationY);
265 
270  virtual void RenderForImageCapture() { this->StillRender(); }
271 
282  virtual vtkTypeUInt32 PreRender(bool vtkNotUsed(interactive)) { return this->GetLocation(); }
283 
284  virtual void PostRender(bool vtkNotUsed(interactive)) {}
285 
295  virtual bool IsContextReadyForRendering();
296 
300  void CreateVTKObjects() override;
301 
305  int ReadXMLAttributes(vtkSMSessionProxyManager* pm, vtkPVXMLElement* element) override;
306 
311  bool GetLocalProcessSupportsInteraction();
312 
316  vtkGetObjectMacro(DeliveryManager, vtkSMDataDeliveryManagerProxy);
317 
318  vtkSetStringMacro(DefaultRepresentationName);
320 
321  bool Enable;
322 
323 private:
324  vtkSMViewProxy(const vtkSMViewProxy&) = delete;
325  void operator=(const vtkSMViewProxy&) = delete;
326 
327  bool InRender;
328 
329  vtkSMDataDeliveryManagerProxy* DeliveryManager;
330  static bool TransparentBackground;
331 
332  // Actual logic for taking a screenshot.
333  vtkImageData* CaptureWindowSingle(int magnificationX, int magnificationY);
334 
335  friend class vtkSMViewProxyNS::WindowToImageFilter;
336  friend class vtkSMViewProxyNS::CaptureHelper;
337 };
338 
339 #endif
Proxy for a representations.
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...
#define VTK_NEWINSTANCE
virtual bool HasDirtyRepresentation()
Return true any internal representation is dirty.
VTK_NEWINSTANCE vtkImageData * CaptureWindow(int magnification)
Captures a image from this view.
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...