vtkSMViewLayoutProxy.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
28 #ifndef vtkSMViewLayoutProxy_h
29 #define vtkSMViewLayoutProxy_h
30 
31 #include "vtkRemotingViewsModule.h" //needed for exports
32 #include "vtkSMProxy.h"
33 #include "vtkVector.h" // needed for vtkVector2i
34 #include <vector> // needed for std::vector.
35 
36 class vtkSMViewProxy;
37 class vtkImageData;
38 
40 {
41 public:
42  static vtkSMViewLayoutProxy* New();
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
46  enum Direction
47  {
50  HORIZONTAL
51  };
52 
62  int Split(int location, int direction, double fraction);
63  int SplitVertical(int location, double fraction)
64  {
65  return this->Split(location, VERTICAL, fraction);
66  }
67  int SplitHorizontal(int location, double fraction)
68  {
69  return this->Split(location, HORIZONTAL, fraction);
70  }
71 
76  bool AssignView(int location, vtkSMViewProxy* view);
77 
87  int AssignViewToAnyCell(vtkSMViewProxy* view, int location_hint);
88 
90 
94  int RemoveView(vtkSMViewProxy* view);
95  bool RemoveView(int index);
97 
104  bool Collapse(int location);
105 
110  bool SwapCells(int location1, int location2);
111 
116  bool SetSplitFraction(int location, double fraction);
117 
121  bool EqualizeViews();
122 
126  bool EqualizeViews(Direction direction);
127 
134  bool MaximizeCell(int location);
135 
139  void RestoreMaximizedState();
140 
142 
146  vtkGetMacro(MaximizedCell, int);
148 
152  bool IsSplitCell(int location);
153 
157  Direction GetSplitDirection(int location);
158 
162  double GetSplitFraction(int location);
163 
168  static int GetFirstChild(int location) { return 2 * location + 1; }
169 
174  static int GetSecondChild(int location) { return 2 * location + 2; }
175 
179  static int GetParent(int location) { return (location > 0 ? ((location - 1) / 2) : -1); }
180 
184  vtkSMViewProxy* GetView(int location);
185 
190  int GetViewLocation(vtkSMViewProxy*);
191 
193 
196  bool ContainsView(vtkSMViewProxy* view) { return this->GetViewLocation(view) != -1; }
197  bool ContainsView(vtkSMProxy* view);
199 
205  void UpdateViewPositions();
206 
212  void ShowViewsOnTileDisplay();
213 
215 
218  vtkImageData* CaptureWindow(int magnification)
219  {
220  return this->CaptureWindow(magnification, magnification);
221  }
222  vtkImageData* CaptureWindow(int magnificationX, int magnificationY);
224 
229  {
230  return this->Superclass::SaveXMLState(root);
231  }
233 
237  int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator) override;
238 
242  void Reset();
243 
247  void GetLayoutExtent(int extent[4]);
248 
250 
255  void SetSize(const int size[2]);
256  void SetSize(int width, int height)
257  {
258  const int size[] = { width, height };
259  this->SetSize(size);
260  }
262 
267  {
268  int extent[4];
269  this->GetLayoutExtent(extent);
270  return vtkVector2i(extent[1] - extent[0] + 1, extent[3] - extent[2] + 1);
271  }
272 
277  static vtkSMViewLayoutProxy* FindLayout(vtkSMViewProxy*, const char* reggroup = "layouts");
278 
282  std::vector<vtkSMViewProxy*> GetViews();
283 
285 
291  void SaveAsPNG(int rank, const char* fname);
293 
294 protected:
296  ~vtkSMViewLayoutProxy() override;
297 
301  void LoadState(const vtkSMMessage* message, vtkSMProxyLocator* locator) override;
302 
308  virtual void UpdateState();
309 
315  int GetEmptyCell(int root);
316 
320  int GetSplittableCell(int root, Direction& suggested_direction);
321 
326  int ComputeSteadySplitFraction(int location, Direction direction);
327 
329 
330 private:
332  void operator=(const vtkSMViewLayoutProxy&) = delete;
333 
334  class vtkInternals;
335  vtkInternals* Internals;
336 
337  bool SetBlockUpdate(bool new_value)
338  {
339  bool temp = this->BlockUpdate;
340  this->BlockUpdate = new_value;
341  return temp;
342  }
343 
344  bool BlockUpdate;
345 
346  bool SetBlockUpdateViewPositions(bool val)
347  {
348  bool temp = this->BlockUpdateViewPositions;
349  this->BlockUpdateViewPositions = val;
350  return temp;
351  }
352  bool BlockUpdateViewPositions;
353 };
354 
355 #endif
static int GetParent(int location)
Returns the parent index.
direction
location
#define VTKREMOTINGVIEWS_EXPORT
static int GetFirstChild(int location)
Returns the index for the first child of the given location.
void PrintSelf(ostream &os, vtkIndent indent) override
vtkImageData * CaptureWindow(int magnification)
Captures an image from the layout (including all the views in the layout.
Superclass for all view proxies.
bool ContainsView(vtkSMViewProxy *view)
Returns if a view is contained in this layout.
void SetSize(int width, int height)
Update the size for all the views in the layout assuming the new size provided for the whole layout...
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
vtkPVXMLElement * SaveXMLState(vtkPVXMLElement *root) override
Overridden to save custom XML state.
size
void LoadState(const vtkSMMessage *msg, vtkSMProxyLocator *locator) override
This method is used to initialise the object to the given state If the definitionOnly Flag is set to ...
vtkSMViewLayoutProxy is used by ParaView to layout multiple views in a 2D KD-Tree layout...
static vtkSMProxy * New()
virtual int LoadXMLState(vtkPVXMLElement *element, vtkSMProxyLocator *locator)
Loads the proxy state from the XML element.
proxy for a VTK object(s) on a server
Definition: vtkSMProxy.h:140
is used to locate proxies referred to in state xmls while loading state files.
int SplitVertical(int location, double fraction)
int SplitHorizontal(int location, double fraction)
void operator=(const vtkSMProxy &)=delete
vtkSMProxyInternals * Internals
Definition: vtkSMProxy.h:1002
virtual vtkPVXMLElement * SaveXMLState(vtkPVXMLElement *root)
Saves the state of the proxy.
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
extent
index
static int GetSecondChild(int location)
Returns the index for the second child of the given location.
vtkVector2i GetSize()
Returns the current size.
iterates over the properties of a proxy