vtkPlotBox.h 4.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPlotBox.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.

=========================================================================*/

16 17 18 19 20 21 22 23
/**
 * @class   vtkPlotBox
 * @brief   Class for drawing box plots.
 *
 *
 * Plots to draw box plots given columns from a vtkTable that may contains
 * 5 lines with quartiles and median.
*/
24

25 26
#ifndef vtkPlotBox_h
#define vtkPlotBox_h
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

#include "vtkChartsCoreModule.h" // For export macro
#include "vtkPlot.h"
#include "vtkStdString.h"       // For vtkStdString ivars

class vtkBrush;
class vtkTextProperty;
class vtkTable;
class vtkStdString;
class vtkScalarsToColors;

class VTKCHARTSCORE_EXPORT vtkPlotBox : public vtkPlot
{
public:
  vtkTypeMacro(vtkPlotBox, vtkPlot);
  virtual void PrintSelf(ostream &os, vtkIndent indent);

44 45 46
  /**
   * Creates a box plot.
   */
47 48
  static vtkPlotBox* New();

49 50 51 52 53
  /**
   * Perform any updates to the item that may be necessary before rendering.
   * The scene should take care of calling this on all items before their
   * Paint function is invoked.
   */
54 55
  virtual void Update();

56 57 58
  /**
   * Paint event for the plot, called whenever the chart needs to be drawn
   */
59 60
  virtual bool Paint(vtkContext2D *painter);

61 62 63 64 65 66
  /**
   * Paint legend event for the plot, called whenever the legend needs the
   * plot items symbol/mark/line drawn. A rect is supplied with the lower left
   * corner of the rect (elements 0 and 1) and with width x height (elements 2
   * and 3). The plot can choose how to fill the space supplied.
   */
67 68 69
  virtual bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
                           int legendIndex);

70 71 72 73
  //@{
  /**
   * This is a convenience function to set the input table.
   */
74 75 76 77 78 79
  virtual void SetInputData(vtkTable *table);
  virtual void SetInputData(vtkTable *table, const vtkStdString&,
                            const vtkStdString&)
  {
    this->SetInputData(table);
  }
80
  //@}
81

82 83 84 85
  /**
   * Get the plot labels. If this array has a length greater than 1 the index
   * refers to the stacked objects in the plot.
   */
86 87
  virtual vtkStringArray *GetLabels();

88 89 90 91 92
  /**
   * Function to query a plot for the nearest point to the specified coordinate.
   * Returns the index of the data series with which the point is associated
   * or -1.
   */
93 94 95 96
  virtual vtkIdType GetNearestPoint(const vtkVector2f& point,
                                    const vtkVector2f& tolerance,
                                    vtkVector2f* location);

97 98 99 100
  //@{
  /**
   * Specify a lookup table for the mapper to use.
   */
101 102
  void SetLookupTable(vtkScalarsToColors *lut);
  vtkScalarsToColors *GetLookupTable();
103
  //@}
104

105 106 107
  /**
   * Helper function to set the color of a given column.
   */
108 109
  void SetColumnColor(const vtkStdString& colName, double *rgb);

110 111 112 113
  /**
   * Create default lookup table. Generally used to create one when none
   * is available with the scalar data.
   */
114 115
  virtual void CreateDefaultLookupTable();

116 117 118 119
  //@{
  /**
   * Get/Set the width of boxes.
   */
120 121
  vtkGetMacro(BoxWidth, float);
  vtkSetMacro(BoxWidth, float);
122
  //@}
123

124 125 126 127
  //@{
  /**
   * Get the vtkTextProperty that governs how the plot title is displayed.
   */
128
  vtkGetObjectMacro(TitleProperties, vtkTextProperty);
129
  //@}
130 131 132 133 134 135 136

protected:
  vtkPlotBox();
  ~vtkPlotBox();

  void DrawBoxPlot(int, unsigned char*, double, vtkContext2D*);

137 138 139
  /**
   * Update the table cache.
   */
140 141
  bool UpdateTableCache(vtkTable *table);

142 143 144 145
  //@{
  /**
   * Store a well packed set of XY coordinates for this data series.
   */
146 147
  class Private;
  Private* Storage;
148
  //@}
149

150 151 152
  /**
   * The point cache is marked dirty until it has been initialized.
   */
153 154
  vtkTimeStamp BuildTime;

155 156 157
  /**
   * Width of boxes.
   */
158 159
  float BoxWidth;

160 161 162
  /**
   * Lookup Table for coloring points by scalar value
   */
163 164
  vtkScalarsToColors *LookupTable;

165 166 167
  /**
   * Text properties for the plot title
   */
168 169 170
  vtkTextProperty* TitleProperties;

private:
171
  vtkPlotBox(const vtkPlotBox &) VTK_DELETE_FUNCTION;
172
  void operator=(const vtkPlotBox &) VTK_DELETE_FUNCTION;
173 174 175

};

176
#endif //vtkPlotBox_h