vtkSMViewProxy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkSMViewProxy.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
32 #ifndef vtkSMViewProxy_h
33 #define vtkSMViewProxy_h
34 
35 #include "vtkCommand.h" // needed for vtkCommand.
36 #include "vtkRemotingViewsModule.h" //needed for exports
37 #include "vtkSMProxy.h"
38 
39 class vtkImageData;
40 class vtkRenderer;
41 class vtkRenderWindow;
45 class vtkSMSourceProxy;
46 class vtkView;
47 
49 {
50 class WindowToImageFilter;
51 class CaptureHelper;
52 }
53 
54 class VTKREMOTINGVIEWS_EXPORT vtkSMViewProxy : public vtkSMProxy
55 {
56 public:
57  static vtkSMViewProxy* New();
58  vtkTypeMacro(vtkSMViewProxy, vtkSMProxy);
59  void PrintSelf(ostream& os, vtkIndent indent) override;
60 
62 
65  vtkSetMacro(Enable, bool);
66  vtkGetMacro(Enable, bool);
67  vtkBooleanMacro(Enable, bool);
69 
73  virtual void StillRender();
74 
78  virtual void InteractiveRender();
79 
83  virtual void Update();
84 
90  virtual bool CanDisplayData(vtkSMSourceProxy* producer, int outputPort);
91 
100  virtual vtkSMRepresentationProxy* CreateDefaultRepresentation(vtkSMProxy*, int);
101 
111  virtual const char* GetRepresentationType(vtkSMSourceProxy* producer, int outputPort);
112 
117  virtual vtkSMRepresentationProxy* FindRepresentation(vtkSMSourceProxy* producer, int outputPort);
118 
120 
125  vtkImageData* CaptureWindow(int magnification)
126  {
127  return this->CaptureWindow(magnification, magnification);
128  }
129  vtkImageData* CaptureWindow(int magnificationX, int magnificationY);
131 
134  vtkView* GetClientSideView();
135 
140  int WriteImage(const char* filename, const char* writerName, int magnification = 1);
141  int WriteImage(
142  const char* filename, const char* writerName, int magnificationX, int magnificationY);
143 
149  virtual bool HasDirtyRepresentation() { return this->GetNeedsUpdate(); }
150 
152 
157  vtkGetMacro(NeedsUpdate, bool);
159 
168  virtual vtkRenderWindow* GetRenderWindow() { return NULL; }
169 
175  virtual vtkRenderWindowInteractor* GetInteractor() { return NULL; }
176 
186  virtual void SetupInteractor(vtkRenderWindowInteractor* iren) { (void)iren; }
187 
195  virtual bool MakeRenderWindowInteractor(bool quiet = false);
196 
198 
201  static void SetTransparentBackground(bool val);
202  static bool GetTransparentBackground();
204 
206 
215  virtual bool HideOtherRepresentationsIfNeeded(vtkSMProxy* repr);
217  {
218  return self ? self->HideOtherRepresentationsIfNeeded(repr) : false;
219  }
221 
223 
236  virtual void RepresentationVisibilityChanged(vtkSMProxy* repr, bool new_visibility);
238  vtkSMViewProxy* self, vtkSMProxy* repr, bool new_visibility)
239  {
240  if (self)
241  {
242  self->RepresentationVisibilityChanged(repr, new_visibility);
243  }
244  }
246 
250  static vtkSMViewProxy* FindView(vtkSMProxy* repr, const char* reggroup = "views");
251 
252  enum
253  {
258  PrepareContextForRendering = vtkCommand::UserEvent + 1,
259  };
260 
261 protected:
262  vtkSMViewProxy();
263  ~vtkSMViewProxy() override;
264 
275  virtual vtkImageData* CaptureWindowInternal(int magnificationX, int magnificationY);
276 
281  virtual void RenderForImageCapture() { this->StillRender(); }
282 
293  virtual vtkTypeUInt32 PreRender(bool vtkNotUsed(interactive)) { return this->GetLocation(); }
294 
295  virtual void PostRender(bool vtkNotUsed(interactive)) {}
296 
306  virtual bool IsContextReadyForRendering();
307 
311  void CreateVTKObjects() override;
312 
316  int ReadXMLAttributes(vtkSMSessionProxyManager* pm, vtkPVXMLElement* element) override;
317 
322  bool GetLocalProcessSupportsInteraction();
323 
327  vtkGetObjectMacro(DeliveryManager, vtkSMDataDeliveryManagerProxy);
328 
329  vtkSetStringMacro(DefaultRepresentationName);
331 
332  bool Enable;
333 
334 private:
335  vtkSMViewProxy(const vtkSMViewProxy&) = delete;
336  void operator=(const vtkSMViewProxy&) = delete;
337 
338  vtkSMDataDeliveryManagerProxy* DeliveryManager;
339  static bool TransparentBackground;
340 
341  // Actual logic for taking a screenshot.
342  vtkImageData* CaptureWindowSingle(int magnificationX, int magnificationY);
343 
344  friend class vtkSMViewProxyNS::WindowToImageFilter;
345  friend class vtkSMViewProxyNS::CaptureHelper;
346 };
347 
348 #endif
Proxy for a representations.
vtkImageData * CaptureWindow(int magnification)
Captures a image from this view.
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:152
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...