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 
51 class VTKREMOTINGVIEWS_EXPORT vtkSMViewLayoutProxy : public vtkSMProxy
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 
255  void SetSize(const int size[2]);
257  {
258  int extent[4];
259  this->GetLayoutExtent(extent);
260  return vtkVector2i(extent[1] - extent[0] + 1, extent[3] - extent[2] + 1);
261  }
262 
267  static vtkSMViewLayoutProxy* FindLayout(vtkSMViewProxy*, const char* reggroup = "layouts");
268 
272  std::vector<vtkSMViewProxy*> GetViews();
273 
275 
281  void SaveAsPNG(int rank, const char* fname);
283 
284 protected:
286  ~vtkSMViewLayoutProxy() override;
287 
291  void LoadState(const vtkSMMessage* message, vtkSMProxyLocator* locator) override;
292 
298  virtual void UpdateState();
299 
305  int GetEmptyCell(int root);
306 
310  int GetSplittableCell(int root, Direction& suggested_direction);
311 
313 
314 private:
316  void operator=(const vtkSMViewLayoutProxy&) = delete;
317 
318  class vtkInternals;
319  vtkInternals* Internals;
320 
321  bool SetBlockUpdate(bool new_value)
322  {
323  bool temp = this->BlockUpdate;
324  this->BlockUpdate = new_value;
325  return temp;
326  }
327 
328  bool BlockUpdate;
329 
330  bool SetBlockUpdateViewPositions(bool val)
331  {
332  bool temp = this->BlockUpdateViewPositions;
333  this->BlockUpdateViewPositions = val;
334  return temp;
335  }
336  bool BlockUpdateViewPositions;
337 };
338 
339 #endif
static int GetParent(int location)
Returns the parent index.
location
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.
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.
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:1001
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
static int GetSecondChild(int location)
Returns the index for the second child of the given location.
iterates over the properties of a proxy