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
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCategoryLegend.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.
=========================================================================*/
/**
* @class vtkCategoryLegend
* @brief Legend item to display categorical data.
*
* vtkCategoryLegend will display a label and color patch for each value
* in a categorical data set. To use this class, you must first populate
* a vtkScalarsToColors by using the SetAnnotation() method. The other
* input to this class is a vtkVariantArray. This should contain the
* annotated values from the vtkScalarsToColors that you wish to include
* within the legend.
*/
#ifndef vtkCategoryLegend_h
#define vtkCategoryLegend_h
#include "vtkChartsCoreModule.h" // For export macro
#include "vtkChartLegend.h"
#include "vtkNew.h" // For vtkNew ivars
#include "vtkStdString.h" // For vtkStdString ivars
#include "vtkVector.h" // For vtkRectf
class vtkScalarsToColors;
class vtkTextProperty;
class vtkVariantArray;
class VTKCHARTSCORE_EXPORT vtkCategoryLegend: public vtkChartLegend
{
public:
vtkTypeMacro(vtkCategoryLegend, vtkChartLegend);
static vtkCategoryLegend* New();
/**
* Enum of legend orientation types
*/
enum {
VERTICAL = 0,
HORIZONTAL
};
/**
* Paint the legend into a rectangle defined by the bounds.
*/
virtual bool Paint(vtkContext2D *painter);
/**
* Compute and return the lower left corner of this legend, along
* with its width and height.
*/
virtual vtkRectf GetBoundingRect(vtkContext2D* painter);
//@{
/**
* Get/Set the vtkScalarsToColors used to draw this legend.
* Since this legend represents categorical data, this
* vtkScalarsToColors must have been populated using SetAnnotation().
*/
virtual void SetScalarsToColors(vtkScalarsToColors* stc);
virtual vtkScalarsToColors * GetScalarsToColors();
//@}
//@{
/**
* Get/Set the array of values that will be represented by this legend.
* This array must contain distinct annotated values from the ScalarsToColors.
* Each value in this array will be drawn as a separate entry within this
* legend.
*/
vtkGetMacro(Values, vtkVariantArray*);
vtkSetMacro(Values, vtkVariantArray*);
//@}
//@{
/**
* Get/set the title text of the legend.
*/
virtual void SetTitle(const vtkStdString &title);
virtual vtkStdString GetTitle();
//@}
//@{
/**
* Get/set the label to use for outlier data.
*/
vtkGetMacro(OutlierLabel, vtkStdString);
vtkSetMacro(OutlierLabel, vtkStdString);
//@}
protected:
vtkCategoryLegend();
virtual ~vtkCategoryLegend();
bool HasOutliers;
float TitleWidthOffset;
vtkScalarsToColors* ScalarsToColors;
vtkStdString OutlierLabel;
vtkStdString Title;
vtkNew<vtkTextProperty> TitleProperties;
vtkVariantArray* Values;
private:
vtkCategoryLegend(const vtkCategoryLegend &) VTK_DELETE_FUNCTION;
void operator=(const vtkCategoryLegend &) VTK_DELETE_FUNCTION;
};
#endif
|