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 
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 
140 
145  vtkGetMacro(NeedsUpdate, bool);
147 
156  virtual vtkRenderWindow* GetRenderWindow() { return nullptr; }
157 
163  virtual vtkRenderWindowInteractor* GetInteractor() { return nullptr; }
164 
174  virtual void SetupInteractor(vtkRenderWindowInteractor* iren) { (void)iren; }
175 
183  virtual bool MakeRenderWindowInteractor(bool quiet = false);
184 
186 
189  static void SetTransparentBackground(bool val);
190  static bool GetTransparentBackground();
192 
194 
203  virtual bool HideOtherRepresentationsIfNeeded(vtkSMProxy* repr);
205  {
206  return self ? self->HideOtherRepresentationsIfNeeded(repr) : false;
207  }
209 
211 
224  virtual void RepresentationVisibilityChanged(vtkSMProxy* repr, bool new_visibility);
226  vtkSMViewProxy* self, vtkSMProxy* repr, bool new_visibility)
227  {
228  if (self)
229  {
230  self->RepresentationVisibilityChanged(repr, new_visibility);
231  }
232  }
234 
238  static vtkSMViewProxy* FindView(vtkSMProxy* repr, const char* reggroup = "views");
239 
240  enum
241  {
246  PrepareContextForRendering = vtkCommand::UserEvent + 1,
247  };
248 
249 protected:
250  vtkSMViewProxy();
251  ~vtkSMViewProxy() override;
252 
263  virtual vtkImageData* CaptureWindowInternal(int magnificationX, int magnificationY);
264 
269  virtual void RenderForImageCapture() { this->StillRender(); }
270 
281  virtual vtkTypeUInt32 PreRender(bool vtkNotUsed(interactive)) { return this->GetLocation(); }
282 
283  virtual void PostRender(bool vtkNotUsed(interactive)) {}
284 
294  virtual bool IsContextReadyForRendering();
295 
299  void CreateVTKObjects() override;
300 
304  int ReadXMLAttributes(vtkSMSessionProxyManager* pm, vtkPVXMLElement* element) override;
305 
310  bool GetLocalProcessSupportsInteraction();
311 
315  vtkGetObjectMacro(DeliveryManager, vtkSMDataDeliveryManagerProxy);
316 
317  vtkSetStringMacro(DefaultRepresentationName);
319 
320  bool Enable;
321 
322 private:
323  vtkSMViewProxy(const vtkSMViewProxy&) = delete;
324  void operator=(const vtkSMViewProxy&) = delete;
325 
326  bool InRender;
327 
328  vtkSMDataDeliveryManagerProxy* DeliveryManager;
329  static bool TransparentBackground;
330 
331  // Actual logic for taking a screenshot.
332  vtkImageData* CaptureWindowSingle(int magnificationX, int magnificationY);
333 
334  friend class vtkSMViewProxyNS::WindowToImageFilter;
335  friend class vtkSMViewProxyNS::CaptureHelper;
336 };
337 
338 #endif
vtkSMSessionProxyManager
Definition: vtkSMSessionProxyManager.h:135
vtkSMProxy::New
static vtkSMProxy * New()
vtkSMProxy::CreateVTKObjects
virtual void CreateVTKObjects()
Given a class name (by setting VTKClassName) and server ids (by setting ServerIDs),...
vtkSMViewProxy::SetupInteractor
virtual void SetupInteractor(vtkRenderWindowInteractor *iren)
A client process need to set the interactor to enable interactivity.
Definition: vtkSMViewProxy.h:174
vtkSMRepresentationProxy
Proxy for a representations.
Definition: vtkSMRepresentationProxy.h:76
vtkSMViewProxy::CaptureWindow
vtkImageData * CaptureWindow(int magnification)
Captures a image from this view.
Definition: vtkSMViewProxy.h:113
vtkSMDataDeliveryManagerProxy
server-manager class for vtkPVDataDeliveryManager.
Definition: vtkSMDataDeliveryManagerProxy.h:29
vtkSMViewProxy::RenderForImageCapture
virtual void RenderForImageCapture()
This method is called whenever the view wants to render to during image capture.
Definition: vtkSMViewProxy.h:269
vtkCommand.h
vtkSMViewProxy::PostRender
virtual void PostRender(bool vtkNotUsed(interactive))
Definition: vtkSMViewProxy.h:283
vtkSMProxy
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
vtkSMViewProxy::GetRenderWindow
virtual vtkRenderWindow * GetRenderWindow()
Return the vtkRenderWindow used by this view, if any.
Definition: vtkSMViewProxy.h:156
Update
virtual void Update()
vtkSMProxy::ReadXMLAttributes
virtual int ReadXMLAttributes(vtkSMSessionProxyManager *pm, vtkPVXMLElement *element)
Read attributes from an XML element.
vtkSMViewProxy::PreRender
virtual vtkTypeUInt32 PreRender(bool vtkNotUsed(interactive))
This method is called before executing code that could cause a render on the underlying vtkPVView.
Definition: vtkSMViewProxy.h:281
vtkSMSourceProxy
proxy for a VTK source on a server
Definition: vtkSMSourceProxy.h:37
vtkSMViewProxyNS
Definition: vtkSMViewProxy.h:36
vtkView
vtkSMProxy::operator=
void operator=(const vtkSMProxy &)=delete
vtkSMViewProxy::GetInteractor
virtual vtkRenderWindowInteractor * GetInteractor()
Returns the interactor.
Definition: vtkSMViewProxy.h:163
vtkImageData
vtkIndent
vtkSMViewProxy::DefaultRepresentationName
char * DefaultRepresentationName
Definition: vtkSMViewProxy.h:317
vtkSMProxy::vtkSMViewProxy
friend class vtkSMViewProxy
These classes have been declared as friends to minimize the public interface exposed by vtkSMProxy.
Definition: vtkSMProxy.h:692
vtkRenderWindowInteractor
vtkSMViewProxy::Enable
bool Enable
Definition: vtkSMViewProxy.h:320
vtkSMViewProxy::HideOtherRepresentationsIfNeeded
static bool HideOtherRepresentationsIfNeeded(vtkSMViewProxy *self, vtkSMProxy *repr)
Method used to hide other representations if the view has a <ShowOneRepresentationAtATime/> hint.
Definition: vtkSMViewProxy.h:204
vtkSMViewProxy
Superclass for all view proxies.
Definition: vtkSMViewProxy.h:42
vtkPVXMLElement
Definition: vtkPVXMLElement.h:23
vtkSMProxy.h
vtkRenderer
vtkSMProxy::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
vtkRenderWindow
vtkSMViewProxy::RepresentationVisibilityChanged
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...
Definition: vtkSMViewProxy.h:225
vtkSMViewProxy::HasDirtyRepresentation
virtual bool HasDirtyRepresentation()
Return true any internal representation is dirty.
Definition: vtkSMViewProxy.h:137
vtkSMRemoteObject::GetLocation
virtual vtkTypeUInt32 GetLocation()
Get/Set the location where the underlying VTK-objects are created.