1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCornerAnnotation.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkCornerAnnotation - text annotation in four corners
// .SECTION Description
// This is an annotation object that manages four text actors / mappers
// to provide annotation in the four corners of a viewport
//
// .SECTION Special input text:
// - <image> : will be replaced with slice number (relative number)
// - <slice> : will be replaced with slice number (relative number)
// - <image_and_max> : will be replaced with slice number and slice max (relative)
// - <slice_and_max> : will be replaced with slice number and slice max (relative)
// - <slice_pos> : will be replaced by the position of the current slice
// - <window> : will be replaced with window value
// - <level> : will be replaced with level value
// - <window_level> : will be replaced with window and level value
//
// .SECTION See Also
// vtkActor2D vtkTextMapper
#ifndef vtkCornerAnnotation_h
#define vtkCornerAnnotation_h
#include "vtkRenderingAnnotationModule.h" // For export macro
#include "vtkActor2D.h"
class vtkTextMapper;
class vtkImageMapToWindowLevelColors;
class vtkImageActor;
class vtkTextProperty;
class VTKRENDERINGANNOTATION_EXPORT vtkCornerAnnotation : public vtkActor2D
{
public:
vtkTypeMacro(vtkCornerAnnotation,vtkActor2D);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Instantiate object with a rectangle in normaled view coordinates
// of (0.2,0.85, 0.8, 0.95).
static vtkCornerAnnotation *New();
// Description:
// Draw the scalar bar and annotation text to the screen.
int RenderOpaqueGeometry(vtkViewport* viewport);
virtual int RenderTranslucentPolygonalGeometry(vtkViewport* ) {return 0;};
int RenderOverlay(vtkViewport* viewport);
// Description:
// Does this prop have some translucent polygonal geometry?
virtual int HasTranslucentPolygonalGeometry();
// Description:
// Set/Get the maximum height of a line of text as a
// percentage of the vertical area allocated to this
// scaled text actor. Defaults to 1.0
vtkSetMacro(MaximumLineHeight,double);
vtkGetMacro(MaximumLineHeight,double);
// Description:
// Set/Get the minimum/maximum size font that will be shown.
// If the font drops below the minimum size it will not be rendered.
vtkSetMacro(MinimumFontSize,int);
vtkGetMacro(MinimumFontSize,int);
vtkSetMacro(MaximumFontSize,int);
vtkGetMacro(MaximumFontSize,int);
// Description:
// Set/Get font scaling factors
// The font size, f, is calculated as the largest possible value
// such that the annotations for the given viewport do not overlap.
// This font size is scaled non-linearly with the viewport size,
// to maintain an acceptable readable size at larger viewport sizes,
// without being too big.
// f' = linearScale * pow(f,nonlinearScale)
vtkSetMacro( LinearFontScaleFactor, double );
vtkGetMacro( LinearFontScaleFactor, double );
vtkSetMacro( NonlinearFontScaleFactor, double );
vtkGetMacro( NonlinearFontScaleFactor, double );
// Description:
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
virtual void ReleaseGraphicsResources(vtkWindow *);
// Description:
// Position used to get or set the corner annotation text.
// \sa GetText(), SetText()
enum TextPosition
{
LowerLeft = 0, ///< Uses the lower left corner.
LowerRight, ///< Uses the lower right corner.
UpperLeft, ///< Uses the upper left corner.
UpperRight, ///< Uses the upper right corner.
LowerEdge, ///< Uses the lower edge center.
RightEdge, ///< Uses the right edge center.
LeftEdge, ///< Uses the left edge center
UpperEdge ///< Uses the upper edge center.
};
static const int NumTextPositions = 8;
// Description:
// Set/Get the text to be displayed for each corner
// \sa TextPosition
void SetText(int i, const char *text);
const char* GetText(int i);
void ClearAllTexts();
void CopyAllTextsFrom(vtkCornerAnnotation *ca);
// Description:
// Set an image actor to look at for slice information
void SetImageActor(vtkImageActor*);
vtkGetObjectMacro(ImageActor,vtkImageActor);
// Description:
// Set an instance of vtkImageMapToWindowLevelColors to use for
// looking at window level changes
void SetWindowLevel(vtkImageMapToWindowLevelColors*);
vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors);
// Description:
// Set the value to shift the level by.
vtkSetMacro(LevelShift, double);
vtkGetMacro(LevelShift, double);
// Description:
// Set the value to scale the level by.
vtkSetMacro(LevelScale, double);
vtkGetMacro(LevelScale, double);
// Description:
// Set/Get the text property of all corners.
virtual void SetTextProperty(vtkTextProperty *p);
vtkGetObjectMacro(TextProperty,vtkTextProperty);
// Description:
// Even if there is an image actor, should `slice' and `image' be displayed?
vtkBooleanMacro(ShowSliceAndImage, int);
vtkSetMacro(ShowSliceAndImage, int);
vtkGetMacro(ShowSliceAndImage, int);
protected:
vtkCornerAnnotation();
~vtkCornerAnnotation();
double MaximumLineHeight;
vtkTextProperty *TextProperty;
vtkImageMapToWindowLevelColors *WindowLevel;
double LevelShift;
double LevelScale;
vtkImageActor *ImageActor;
vtkImageActor *LastImageActor;
char *CornerText[NumTextPositions];
int FontSize;
vtkActor2D *TextActor[NumTextPositions];
vtkTimeStamp BuildTime;
int LastSize[2];
vtkTextMapper *TextMapper[NumTextPositions];
int MinimumFontSize;
int MaximumFontSize;
double LinearFontScaleFactor;
double NonlinearFontScaleFactor;
int ShowSliceAndImage;
// Description:
// Search for replacable tokens and replace
virtual void TextReplace(
vtkImageActor *ia, vtkImageMapToWindowLevelColors *wl);
// Description:
// Set text actor positions given a viewport size and justification
virtual void SetTextActorsPosition(int vsize[2]);
virtual void SetTextActorsJustification();
private:
vtkCornerAnnotation(const vtkCornerAnnotation&); // Not implemented.
void operator=(const vtkCornerAnnotation&); // Not implemented.
};
#endif
|