vtkSMRenderViewProxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
12 #ifndef vtkSMRenderViewProxy_h
13 #define vtkSMRenderViewProxy_h
14 
15 #include "vtkNew.h" // needed for vtkInteractorObserver.
16 #include "vtkRemotingViewsModule.h" //needed for exports
17 #include "vtkSMViewProxy.h"
18 
19 class vtkCamera;
20 class vtkCollection;
21 class vtkFloatArray;
22 class vtkIntArray;
23 class vtkRenderer;
24 class vtkRenderWindow;
26 
27 class VTKREMOTINGVIEWS_EXPORT vtkSMRenderViewProxy : public vtkSMViewProxy
28 {
29 public:
30  static vtkSMRenderViewProxy* New();
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
35 
38  bool SelectSurfaceCells(const int region[4], vtkCollection* selectedRepresentations,
39  vtkCollection* selectionSources, bool multiple_selections = false,
40  int modifier = /* replace */ 0, bool select_blocks = false, const char* arrayName = nullptr);
41  bool SelectSurfacePoints(const int region[4], vtkCollection* selectedRepresentations,
42  vtkCollection* selectionSources, bool multiple_selections = false,
43  int modifier = /* replace */ 0, bool select_blocks = false, const char* arrayName = nullptr);
44  bool SelectFrustumCells(const int region[4], vtkCollection* selectedRepresentations,
45  vtkCollection* selectionSources, bool multiple_selections = false);
46  bool SelectFrustumPoints(const int region[4], vtkCollection* selectedRepresentations,
47  vtkCollection* selectionSources, bool multiple_selections = false);
48  bool SelectPolygonPoints(vtkIntArray* polygon, vtkCollection* selectedRepresentations,
49  vtkCollection* selectionSources, bool multiple_selections = false, int modifier = 0,
50  bool selectBlocks = false);
51  bool SelectPolygonCells(vtkIntArray* polygon, vtkCollection* selectedRepresentations,
52  vtkCollection* selectionSources, bool multiple_selections = false, int modifier = 0,
53  bool selectBlocks = false);
55 
57 
60  bool ComputeVisibleScalarRange(const int region[4], int fieldAssociation, const char* scalarName,
61  int component, double range[]);
62  bool ComputeVisibleScalarRange(
63  int fieldAssociation, const char* scalarName, int component, double range[]);
65 
70  vtkSMRepresentationProxy* Pick(int x, int y);
71 
81  vtkSMRepresentationProxy* PickBlock(int x, int y, unsigned int& flatIndex, int& rank);
82 
91  bool ConvertDisplayToPointOnSurface(const int display_position[2], double world_position[3],
92  double world_normal[3], bool snapOnMeshPoint = false);
93 
99  virtual bool IsSelectionAvailable();
100 
104  void SynchronizeGeometryBounds();
105 
107 
112  void ResetCamera(bool closest = false, double offsetRatio = 0.9);
113  void ResetCamera(double bounds[6], bool closest = false, double offsetRatio = 0.9);
114  void ResetCamera(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax,
115  bool closest = false, double offsetRatio = 0.9);
117 
123  virtual void ZoomTo(vtkSMProxy* representation, bool closest = false, double offsetRatio = 0.9);
124 
126 
130  virtual const char* IsSelectVisibleCellsAvailable();
131  virtual const char* IsSelectVisiblePointsAvailable();
133 
140  void SetupInteractor(vtkRenderWindowInteractor* iren) override;
141 
146 
150  vtkRenderer* GetRenderer();
151 
158  void UpdateVTKObjects() override;
159 
161  {
162  Roll = 0,
163  Elevation,
164  Azimuth,
165  Zoom
166  };
168 
172  vtkCamera* GetActiveCamera();
173  void AdjustActiveCamera(const CameraAdjustmentType&, const double&);
174  void AdjustActiveCamera(const int&, const double&);
175  void AdjustAzimuth(const double& value);
176  void AdjustElevation(const double& value);
177  void AdjustRoll(const double& value);
178  void AdjustZoom(const double& value);
179  void ApplyIsometricView();
180  void ResetActiveCameraToDirection(const double& look_x, const double& look_y,
181  const double& look_z, const double& up_x, const double& up_y, const double& up_z);
182  void ResetActiveCameraToPositiveX();
183  void ResetActiveCameraToNegativeX();
184  void ResetActiveCameraToPositiveY();
185  void ResetActiveCameraToNegativeY();
186  void ResetActiveCameraToPositiveZ();
187  void ResetActiveCameraToNegativeZ();
189 
198  void SynchronizeCameraProperties();
199 
203  virtual bool LastRenderWasInteractive();
204 
209  void Update() override;
210 
214  bool GetNeedsUpdate() override;
215 
220  bool StreamingUpdate(bool render_if_needed);
221 
226  const char* GetRepresentationType(vtkSMSourceProxy* producer, int outputPort) override;
227 
231  vtkRenderWindow* GetRenderWindow() override;
232 
238  vtkSMViewProxyInteractorHelper* GetInteractorHelper();
239 
243  vtkFloatArray* CaptureDepthBuffer();
244 
248  virtual const char* GetSelectionRepresentationProxyName() { return "SelectionRepresentation"; }
249 
254  vtkSMProxy* vtkNotUsed(fromSelectionRep), vtkSMProxy* vtkNotUsed(toSelectionRep))
255  {
256  }
257 
262  void ComputeVisibleBounds(vtkSMProxy* representation, double* bounds);
263 
268  bool ClearSelectionCache(bool force = false);
269 
270 protected:
272  ~vtkSMRenderViewProxy() override;
273 
278  void RenderForImageCapture() override;
279 
283  void UpdateLOD();
284 
289  void MarkDirty(vtkSMProxy* modifiedProxy) override;
290 
291  bool SelectFrustumInternal(const int region[4], vtkCollection* selectedRepresentations,
292  vtkCollection* selectionSources, bool multiple_selections, int fieldAssociation);
293  bool SelectPolygonInternal(vtkIntArray* polygon, vtkCollection* selectedRepresentations,
294  vtkCollection* selectionSources, bool multiple_selections, int fieldAssociation, int modifier,
295  bool selectBlocks);
296 
297  vtkTypeUInt32 PreRender(bool interactive) override;
298  void PostRender(bool interactive) override;
299 
304  bool FetchLastSelection(bool multiple_selections, vtkCollection* selectedRepresentations,
305  vtkCollection* selectionSources, int modifier, bool selectBlocks);
306 
310  void CreateVTKObjects() override;
311 
317  bool IsInSelectionMode();
318 
320 
321  // Internal fields for the observer mechanism that is used to invalidate
322  // the cache of selection when the current user became master
323  unsigned long NewMasterObserverId;
324  void NewMasterCallback(vtkObject* src, unsigned long event, void* data);
325 
327 
328 private:
330  void operator=(const vtkSMRenderViewProxy&) = delete;
331 
336  bool SelectInternal(const vtkClientServerStream& cmd, vtkCollection* selectedRepresentations,
337  vtkCollection* selectionSources, bool multiple_selections, int modifier = /* replace */ 0,
338  bool selectBlocks = false);
339 
341 };
342 
343 #endif
vtkSMViewProxy::New
static vtkSMViewProxy * New()
vtkSMViewProxy::Update
virtual void Update()
Called vtkPVView::Update on the server-side.
vtkSMRenderViewProxy::NewMasterObserverId
unsigned long NewMasterObserverId
Definition: vtkSMRenderViewProxy.h:323
vtkSMViewProxy::CreateVTKObjects
void CreateVTKObjects() override
Called at the end of CreateVTKObjects().
vtkSMViewProxy.h
vtkSMViewProxy::GetRepresentationType
virtual const char * GetRepresentationType(vtkSMSourceProxy *producer, int outputPort)
Returns the xml name of the representation proxy to create to show the data produced in this view,...
vtkSMProxy::MarkDirty
virtual void MarkDirty(vtkSMProxy *modifiedProxy)
Dirty means this algorithm will execute during next update.
vtkSMRenderViewProxy::CopySelectionRepresentationProperties
virtual void CopySelectionRepresentationProperties(vtkSMProxy *vtkNotUsed(fromSelectionRep), vtkSMProxy *vtkNotUsed(toSelectionRep))
Function to copy selection representation properties.
Definition: vtkSMRenderViewProxy.h:253
vtkSMRenderViewProxy
implementation for View that includes render window and renderers.
Definition: vtkSMRenderViewProxy.h:27
vtkSMViewProxy::SetupInteractor
virtual void SetupInteractor(vtkRenderWindowInteractor *iren)
A client process need to set the interactor to enable interactivity.
Definition: vtkSMViewProxy.h:174
vtkFloatArray
vtkSMRepresentationProxy
Proxy for a representations.
Definition: vtkSMRepresentationProxy.h:76
vtkSMProxy::UpdateVTKObjects
virtual void UpdateVTKObjects()
Update the VTK object on the server by pushing the values of all modified properties (un-modified pro...
vtkClientServerStream
Store messages for the interpreter.
Definition: vtkClientServerStream.h:23
vtkObject
vtkSMViewProxy::RenderForImageCapture
virtual void RenderForImageCapture()
This method is called whenever the view wants to render to during image capture.
Definition: vtkSMViewProxy.h:269
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::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
vtkCollection
vtkSMViewProxy::GetRenderWindow
virtual vtkRenderWindow * GetRenderWindow()
Return the vtkRenderWindow used by this view, if any.
Definition: vtkSMViewProxy.h:156
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
vtkSMRenderViewProxy::IsSelectionCached
bool IsSelectionCached
Definition: vtkSMRenderViewProxy.h:319
vtkSMSourceProxy
proxy for a VTK source on a server
Definition: vtkSMSourceProxy.h:37
vtkSMRenderViewProxy::GetSelectionRepresentationProxyName
virtual const char * GetSelectionRepresentationProxyName()
Get the SelectionRepresentation proxy name.
Definition: vtkSMRenderViewProxy.h:248
vtkSMRenderViewProxy::CameraAdjustmentType
CameraAdjustmentType
Definition: vtkSMRenderViewProxy.h:160
vtkSMViewProxy::GetInteractor
virtual vtkRenderWindowInteractor * GetInteractor()
Returns the interactor.
Definition: vtkSMViewProxy.h:163
vtkIndent
vtkIntArray
vtkCamera
vtkNew< vtkSMViewProxyInteractorHelper >
vtkRenderWindowInteractor
vtkSMViewProxy
Superclass for all view proxies.
Definition: vtkSMViewProxy.h:42
vtkNew.h
vtkRenderer
vtkSMRenderViewProxy::NeedsUpdateLOD
bool NeedsUpdateLOD
Definition: vtkSMRenderViewProxy.h:326
vtkSMViewProxyInteractorHelper
helper class that make it easier to hook vtkRenderWindowInteractor and vtkSMViewProxy.
Definition: vtkSMViewProxyInteractorHelper.h:51
vtkSMViewProxy::GetNeedsUpdate
virtual bool GetNeedsUpdate()
Returns true if the subsequent call to Update() will result in an actual update.
vtkRenderWindow
int
int