vtkSMViewLayoutProxy.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
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 =========================================================================*/
40 #ifndef vtkSMViewLayoutProxy_h
41 #define vtkSMViewLayoutProxy_h
42 
43 #include "vtkRemotingViewsModule.h" //needed for exports
44 #include "vtkSMProxy.h"
45 #include "vtkVector.h" // needed for vtkVector2i
46 #include <vector> // needed for std::vector.
47 
48 class vtkSMViewProxy;
49 class vtkImageData;
50 
52 {
53 public:
54  static vtkSMViewLayoutProxy* New();
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
58  enum Direction
59  {
62  HORIZONTAL
63  };
64 
74  int Split(int location, int direction, double fraction);
75  int SplitVertical(int location, double fraction)
76  {
77  return this->Split(location, VERTICAL, fraction);
78  }
79  int SplitHorizontal(int location, double fraction)
80  {
81  return this->Split(location, HORIZONTAL, fraction);
82  }
83 
88  bool AssignView(int location, vtkSMViewProxy* view);
89 
99  int AssignViewToAnyCell(vtkSMViewProxy* view, int location_hint);
100 
102 
106  int RemoveView(vtkSMViewProxy* view);
107  bool RemoveView(int index);
109 
116  bool Collapse(int location);
117 
122  bool SwapCells(int location1, int location2);
123 
128  bool SetSplitFraction(int location, double fraction);
129 
136  bool MaximizeCell(int location);
137 
141  void RestoreMaximizedState();
142 
144 
148  vtkGetMacro(MaximizedCell, int);
150 
154  bool IsSplitCell(int location);
155 
159  Direction GetSplitDirection(int location);
160 
164  double GetSplitFraction(int location);
165 
170  static int GetFirstChild(int location) { return 2 * location + 1; }
171 
176  static int GetSecondChild(int location) { return 2 * location + 2; }
177 
181  static int GetParent(int location) { return (location > 0 ? ((location - 1) / 2) : -1); }
182 
186  vtkSMViewProxy* GetView(int location);
187 
192  int GetViewLocation(vtkSMViewProxy*);
193 
195 
198  bool ContainsView(vtkSMViewProxy* view) { return this->GetViewLocation(view) != -1; }
199  bool ContainsView(vtkSMProxy* view);
201 
207  void UpdateViewPositions();
208 
214  void ShowViewsOnTileDisplay();
215 
217 
220  vtkImageData* CaptureWindow(int magnification)
221  {
222  return this->CaptureWindow(magnification, magnification);
223  }
224  vtkImageData* CaptureWindow(int magnificationX, int magnificationY);
226 
231  {
232  return this->Superclass::SaveXMLState(root);
233  }
235 
239  int LoadXMLState(vtkPVXMLElement* element, vtkSMProxyLocator* locator) override;
240 
244  void Reset();
245 
249  void GetLayoutExtent(int extent[4]);
250 
252 
257  void SetSize(const int size[2]);
258  void SetSize(int width, int height)
259  {
260  const int size[] = { width, height };
261  this->SetSize(size);
262  }
264 
269  {
270  int extent[4];
271  this->GetLayoutExtent(extent);
272  return vtkVector2i(extent[1] - extent[0] + 1, extent[3] - extent[2] + 1);
273  }
274 
279  static vtkSMViewLayoutProxy* FindLayout(vtkSMViewProxy*, const char* reggroup = "layouts");
280 
284  std::vector<vtkSMViewProxy*> GetViews();
285 
287 
293  void SaveAsPNG(int rank, const char* fname);
295 
296 protected:
298  ~vtkSMViewLayoutProxy() override;
299 
303  void LoadState(const vtkSMMessage* message, vtkSMProxyLocator* locator) override;
304 
310  virtual void UpdateState();
311 
317  int GetEmptyCell(int root);
318 
322  int GetSplittableCell(int root, Direction& suggested_direction);
323 
325 
326 private:
328  void operator=(const vtkSMViewLayoutProxy&) = delete;
329 
330  class vtkInternals;
331  vtkInternals* Internals;
332 
333  bool SetBlockUpdate(bool new_value)
334  {
335  bool temp = this->BlockUpdate;
336  this->BlockUpdate = new_value;
337  return temp;
338  }
339 
340  bool BlockUpdate;
341 
342  bool SetBlockUpdateViewPositions(bool val)
343  {
344  bool temp = this->BlockUpdateViewPositions;
345  this->BlockUpdateViewPositions = val;
346  return temp;
347  }
348  bool BlockUpdateViewPositions;
349 };
350 
351 #endif
static int GetParent(int location)
Returns the parent index.
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:152
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:1013
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