1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkGraphLayout.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/ 15 /*------------------------------------------------------------------------- 16 Copyright 2008 Sandia Corporation. 17 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 18 the U.S. Government retains certain rights in this software. 19 -------------------------------------------------------------------------*/ 20 /** 21 * @class vtkGraphLayout 22 * @brief layout a graph in 2 or 3 dimensions 23 * 24 * 25 * This class is a shell for many graph layout strategies which may be set 26 * using the SetLayoutStrategy() function. The layout strategies do the 27 * actual work. 28 * 29 * .SECTION Thanks 30 * Thanks to Brian Wylie from Sandia National Laboratories for adding incremental 31 * layout capabilities. 32 */ 33 34 #ifndef vtkGraphLayout_h 35 #define vtkGraphLayout_h 36 37 #include "vtkGraphAlgorithm.h" 38 #include "vtkInfovisLayoutModule.h" // For export macro 39 40 class vtkAbstractTransform; 41 class vtkEventForwarderCommand; 42 class vtkGraphLayoutStrategy; 43 44 class VTKINFOVISLAYOUT_EXPORT vtkGraphLayout : public vtkGraphAlgorithm 45 { 46 public: 47 static vtkGraphLayout* New(); 48 vtkTypeMacro(vtkGraphLayout, vtkGraphAlgorithm); 49 void PrintSelf(ostream& os, vtkIndent indent) override; 50 51 ///@{ 52 /** 53 * The layout strategy to use during graph layout. 54 */ 55 void SetLayoutStrategy(vtkGraphLayoutStrategy* strategy); 56 vtkGetObjectMacro(LayoutStrategy, vtkGraphLayoutStrategy); 57 ///@} 58 59 /** 60 * Ask the layout algorithm if the layout is complete 61 */ 62 virtual int IsLayoutComplete(); 63 64 /** 65 * Get the modification time of the layout algorithm. 66 */ 67 vtkMTimeType GetMTime() override; 68 69 ///@{ 70 /** 71 * Set the ZRange for the output data. 72 * If the initial layout is planar (i.e. all z coordinates are zero), 73 * the coordinates will be evenly spaced from 0.0 to ZRange. 74 * The default is zero, which has no effect. 75 */ 76 vtkGetMacro(ZRange, double); 77 vtkSetMacro(ZRange, double); 78 ///@} 79 80 ///@{ 81 /** 82 * Transform the graph vertices after the layout. 83 */ 84 vtkGetObjectMacro(Transform, vtkAbstractTransform); 85 virtual void SetTransform(vtkAbstractTransform* t); 86 ///@} 87 88 ///@{ 89 /** 90 * Whether to use the specified transform after layout. 91 */ 92 vtkSetMacro(UseTransform, bool); 93 vtkGetMacro(UseTransform, bool); 94 vtkBooleanMacro(UseTransform, bool); 95 ///@} 96 97 protected: 98 vtkGraphLayout(); 99 ~vtkGraphLayout() override; 100 101 vtkGraphLayoutStrategy* LayoutStrategy; 102 103 /** 104 * This intercepts events from the strategy object and re-emits them 105 * as if they came from the layout engine itself. 106 */ 107 vtkEventForwarderCommand* EventForwarder; 108 109 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; 110 111 private: 112 vtkGraph* LastInput; 113 vtkGraph* InternalGraph; 114 vtkMTimeType LastInputMTime; 115 bool StrategyChanged; 116 double ZRange; 117 vtkAbstractTransform* Transform; 118 bool UseTransform; 119 120 vtkGraphLayout(const vtkGraphLayout&) = delete; 121 void operator=(const vtkGraphLayout&) = delete; 122 }; 123 124 #endif 125