1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkQtTreeRingLabelMapper.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 vtkQtTreeRingLabelMapper 22 * @brief draw text labels on a tree map 23 * 24 * 25 * vtkQtTreeRingLabelMapper is a mapper that renders text on a tree map. 26 * A tree map is a vtkTree with an associated 4-tuple array 27 * used for storing the boundary rectangle for each vertex in the tree. 28 * The user must specify the array name used for storing the rectangles. 29 * 30 * The mapper iterates through the tree and attempts and renders a label 31 * inside the vertex's rectangle as long as the following conditions hold: 32 * 1. The vertex level is within the range of levels specified for labeling. 33 * 2. The label can fully fit inside its box. 34 * 3. The label does not overlap an ancestor's label. 35 * 36 * @sa 37 * vtkLabeledDataMapper 38 * 39 * @par Thanks: 40 * Thanks to Jason Shepherd from 41 * Sandia National Laboratories for help in developing this class. 42 */ 43 44 #ifndef vtkQtTreeRingLabelMapper_h 45 #define vtkQtTreeRingLabelMapper_h 46 47 #include "vtkRenderingQtModule.h" // For export macro 48 #include "vtkLabeledDataMapper.h" 49 50 class QImage; 51 52 class vtkQImageToImageSource; 53 class vtkCoordinate; 54 class vtkDoubleArray; 55 class vtkPlaneSource; 56 class vtkPolyDataMapper2D; 57 class vtkRenderer; 58 class vtkStringArray; 59 class vtkTexture; 60 class vtkTextureMapToPlane; 61 class vtkTree; 62 class vtkUnicodeStringArray; 63 64 class VTKRENDERINGQT_EXPORT vtkQtTreeRingLabelMapper : public vtkLabeledDataMapper 65 { 66 public: 67 static vtkQtTreeRingLabelMapper *New(); 68 vtkTypeMacro(vtkQtTreeRingLabelMapper,vtkLabeledDataMapper); 69 void PrintSelf(ostream& os, vtkIndent indent) override; 70 71 //@{ 72 /** 73 * Draw the text to the screen at each input point. 74 */ 75 void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor) override; 76 void RenderOverlay(vtkViewport *viewport, vtkActor2D *actor) override; 77 //@} 78 79 /** 80 * The input to this filter. 81 */ 82 virtual vtkTree *GetInputTree(); 83 84 /** 85 * The name of the 4-tuple array used for 86 */ 87 virtual void SetSectorsArrayName(const char* name); 88 89 //@{ 90 /** 91 * Set/Get the text property. Note that multiple type text properties 92 * (set with a second integer parameter) are not currently supported, 93 * but are provided to avoid compiler warnings. 94 */ 95 void SetLabelTextProperty(vtkTextProperty *p) override; GetLabelTextProperty()96 vtkTextProperty* GetLabelTextProperty() override 97 { return this->LabelTextProperty; } SetLabelTextProperty(vtkTextProperty * p,int type)98 void SetLabelTextProperty(vtkTextProperty *p, int type) override 99 { this->Superclass::SetLabelTextProperty(p, type); } GetLabelTextProperty(int type)100 vtkTextProperty* GetLabelTextProperty(int type) override 101 { return this->Superclass::GetLabelTextProperty(type); } 102 //@} 103 104 //@{ 105 /** 106 * Set/Get the name of the text rotation array. 107 */ 108 vtkSetStringMacro(TextRotationArrayName); 109 vtkGetStringMacro(TextRotationArrayName); 110 //@} 111 112 /** 113 * Return the object's MTime. This is overridden to include 114 * the timestamp of its internal class. 115 */ 116 vtkMTimeType GetMTime() override; 117 SetRenderer(vtkRenderer * ren)118 void SetRenderer(vtkRenderer* ren) 119 { 120 if (this->Renderer != ren) 121 { 122 this->Renderer = ren; 123 this->Modified(); 124 } 125 } GetRenderer()126 vtkRenderer* GetRenderer() { return this->Renderer; } 127 128 protected: 129 vtkQtTreeRingLabelMapper(); 130 ~vtkQtTreeRingLabelMapper() override; 131 void LabelTree(vtkTree *tree, vtkDataArray *sectorInfo, 132 vtkDataArray *numericData, vtkStringArray *stringData, vtkUnicodeStringArray *uStringData, 133 int activeComp, int numComps, vtkViewport* viewport); 134 void GetVertexLabel(vtkIdType vertex, vtkDataArray *numericData, 135 vtkStringArray *stringData, 136 vtkUnicodeStringArray *uStringData, 137 int activeComp, int numComps, 138 char *string, size_t stringSize); 139 140 //Returns true if the center of the sector is in the window 141 // along with the pixel dimensions (width, height) of the sector 142 bool PointInWindow(double *sinfo, double *newDim, double *textPosDC, vtkViewport *viewport); 143 144 vtkViewport *CurrentViewPort; 145 vtkCoordinate *VCoord; 146 vtkQImageToImageSource* QtImageSource; 147 vtkPlaneSource* PlaneSource; 148 vtkRenderer* Renderer; 149 vtkTextProperty *LabelTextProperty; 150 vtkTexture* LabelTexture; 151 vtkTextureMapToPlane* TextureMapToPlane; 152 char* TextRotationArrayName; 153 vtkPolyDataMapper2D* polyDataMapper; 154 QImage* QtImage; 155 int WindowSize[2]; 156 157 private: 158 vtkQtTreeRingLabelMapper(const vtkQtTreeRingLabelMapper&) = delete; 159 void operator=(const vtkQtTreeRingLabelMapper&) = delete; 160 }; 161 162 163 #endif 164