vtkPlotStacked.h 4.82 KB
Newer Older
Keith Fieldhouse's avatar
Keith Fieldhouse committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPlotPoints.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   vtkPlotStacked
 * @brief   Class for drawing an stacked polygon plot
 * given an X, Ybase, Yextent  in a vtkTable.
 *
 *
 *
*/
Keith Fieldhouse's avatar
Keith Fieldhouse committed
24

25 26
#ifndef vtkPlotStacked_h
#define vtkPlotStacked_h
Keith Fieldhouse's avatar
Keith Fieldhouse committed
27

28
#include "vtkChartsCoreModule.h" // For export macro
Keith Fieldhouse's avatar
Keith Fieldhouse committed
29 30 31 32 33 34 35 36
#include "vtkPlot.h"

class vtkChartXY;
class vtkContext2D;
class vtkTable;
class vtkPoints2D;
class vtkStdString;
class vtkImageData;
37 38 39
class vtkColorSeries;

class vtkPlotStackedPrivate;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
40

41
class VTKCHARTSCORE_EXPORT vtkPlotStacked : public vtkPlot
Keith Fieldhouse's avatar
Keith Fieldhouse committed
42 43 44
{
public:
  vtkTypeMacro(vtkPlotStacked, vtkPlot);
45
  void PrintSelf(ostream &os, vtkIndent indent) override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
46

47 48 49
  /**
   * Creates a Stacked Plot Object
   */
Keith Fieldhouse's avatar
Keith Fieldhouse committed
50 51
  static vtkPlotStacked *New();

52 53 54 55
  //@{
  /**
   * Set the plot color
   */
56
  void SetColor(unsigned char r, unsigned char g, unsigned char b,
57 58 59
                        unsigned char a) override;
  void SetColor(double r,  double g, double b) override;
  void GetColor(double rgb[3]) override;
60
  //@}
Keith Fieldhouse's avatar
Keith Fieldhouse committed
61

62 63 64 65 66
  /**
   * 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.
   */
67
  void Update() override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
68

69 70 71
  /**
   * Paint event for the Stacked plot, called whenever the chart needs to be drawn
   */
72
  bool Paint(vtkContext2D *painter) override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
73

74 75 76 77 78 79
  /**
   * Paint legend event for the Stacked 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.
   */
80
  bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
81
                           int legendIndex) override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
82

83 84 85
  /**
   * Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
   */
86
  void GetBounds(double bounds[4]) override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
87

88 89 90 91
  /**
   * Get the unscaled input bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
   * See vtkPlot for more information.
   */
92
  void GetUnscaledInputBounds(double bounds[4]) override;
93

94 95 96
  /**
   * When used to set additional arrays, stacked bars are created.
   */
97
  void SetInputArray(int index, const vtkStdString &name) override;
98

99 100 101
  /**
   * Set the color series to use if this becomes a stacked bar plot.
   */
102 103
  void SetColorSeries(vtkColorSeries *colorSeries);

104 105 106
  /**
   * Get the color series used if when this is a stacked bar plot.
   */
107 108
  vtkColorSeries *GetColorSeries();

109 110 111
  /**
   * Get the plot labels.
   */
112
  vtkStringArray *GetLabels() override;
113

114 115 116 117 118
  /**
   * 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.
   */
119
  vtkIdType GetNearestPoint(const vtkVector2f& point,
120
                                    const vtkVector2f& tolerance,
121
                                    vtkVector2f* location) override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
122

123 124 125
  /**
   * Select all points in the specified rectangle.
   */
126
  bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max) override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
127 128 129

protected:
  vtkPlotStacked();
130
  ~vtkPlotStacked() override;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
131

132 133 134
  /**
   * Update the table cache.
   */
Keith Fieldhouse's avatar
Keith Fieldhouse committed
135 136 137
  bool UpdateTableCache(vtkTable *table);

  // Descript:
138
  // For stacked plots the Extent data must be greater than (or equal to) the
Keith Fieldhouse's avatar
Keith Fieldhouse committed
139 140 141
  // base data. Insure that this is true
  void FixExtent();

142 143 144 145
  /**
   * Handle calculating the log of the x or y series if necessary. Should be
   * called by UpdateTableCache once the data has been updated in Points.
   */
Keith Fieldhouse's avatar
Keith Fieldhouse committed
146 147
  void CalculateLogSeries();

148 149 150 151
  /**
   * An array containing the indices of all the "bad base points", meaning any x, y
   * pair that has an infinity, -infinity or not a number value.
   */
Keith Fieldhouse's avatar
Keith Fieldhouse committed
152 153
  vtkIdTypeArray* BaseBadPoints;

154 155 156 157
  /**
   * An array containing the indices of all the "bad extent points", meaning any x, y
   * pair that has an infinity, -infinity or not a number value.
   */
Keith Fieldhouse's avatar
Keith Fieldhouse committed
158 159
  vtkIdTypeArray* ExtentBadPoints;

160 161 162
  /**
   * The point cache is marked dirty until it has been initialized.
   */
Keith Fieldhouse's avatar
Keith Fieldhouse committed
163 164 165 166
  vtkTimeStamp BuildTime;

  bool LogX, LogY;

167 168 169
  /**
   * The color series to use for each series.
   */
170 171
  vtkSmartPointer<vtkColorSeries> ColorSeries;

Keith Fieldhouse's avatar
Keith Fieldhouse committed
172
private:
173 174
  vtkPlotStacked(const vtkPlotStacked &) = delete;
  void operator=(const vtkPlotStacked &) = delete;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
175

176 177
  vtkPlotStackedPrivate *Private;

Keith Fieldhouse's avatar
Keith Fieldhouse committed
178 179
};

180
#endif //vtkPlotStacked_h