vtkPlotStacked.h 4.92 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 16 17 18 19 20 21
/*=========================================================================

  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.

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

// .NAME vtkPlotStacked - Class for drawing an stacked polygon plot
// given an X, Ybase, Yextent  in a vtkTable.
//
// .SECTION Description
//

22 23
#ifndef vtkPlotStacked_h
#define vtkPlotStacked_h
Keith Fieldhouse's avatar
Keith Fieldhouse committed
24

25
#include "vtkChartsCoreModule.h" // For export macro
Keith Fieldhouse's avatar
Keith Fieldhouse committed
26 27 28 29 30 31 32 33
#include "vtkPlot.h"

class vtkChartXY;
class vtkContext2D;
class vtkTable;
class vtkPoints2D;
class vtkStdString;
class vtkImageData;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
34 35 36
class vtkColorSeries;

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

38
class VTKCHARTSCORE_EXPORT vtkPlotStacked : public vtkPlot
Keith Fieldhouse's avatar
Keith Fieldhouse committed
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
{
public:
  vtkTypeMacro(vtkPlotStacked, vtkPlot);
  virtual void PrintSelf(ostream &os, vtkIndent indent);

  // Description:
  // Creates a Stacked Plot Object
  static vtkPlotStacked *New();

  // Description:
  // Set the plot color
  virtual void SetColor(unsigned char r, unsigned char g, unsigned char b,
                        unsigned char a);
  virtual void SetColor(double r,  double g, double b);
  virtual void GetColor(double rgb[3]);

  // Description:
  // 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.
  virtual void Update();

  // Description:
  // Paint event for the Stacked plot, called whenever the chart needs to be drawn
  virtual bool Paint(vtkContext2D *painter);

  // Description:
  // 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.
70 71
  virtual bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
                           int legendIndex);
Keith Fieldhouse's avatar
Keith Fieldhouse committed
72 73

  // Description:
74
  // Get the bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
Keith Fieldhouse's avatar
Keith Fieldhouse committed
75 76
  virtual void GetBounds(double bounds[4]);

77 78 79 80 81
  // Description:
  // Get the unscaled input bounds for this mapper as (Xmin,Xmax,Ymin,Ymax).
  // See vtkPlot for more information.
  virtual void GetUnscaledInputBounds(double bounds[4]);

Keith Fieldhouse's avatar
Keith Fieldhouse committed
82 83
  // Description:
  // When used to set additional arrays, stacked bars are created.
84
  virtual void SetInputArray(int index, const vtkStdString &name);
Keith Fieldhouse's avatar
Keith Fieldhouse committed
85 86 87 88 89 90 91 92 93 94 95 96 97

  // Description:
  // Set the color series to use if this becomes a stacked bar plot.
  void SetColorSeries(vtkColorSeries *colorSeries);

  // Description:
  // Get the color series used if when this is a stacked bar plot.
  vtkColorSeries *GetColorSeries();

  // Description
  // Get the plot labels.
  virtual vtkStringArray *GetLabels();

Keith Fieldhouse's avatar
Keith Fieldhouse committed
98 99
  // Description:
  // Function to query a plot for the nearest point to the specified coordinate.
100
  // Returns the index of the data series with which the point is associated or
Keith Fieldhouse's avatar
Keith Fieldhouse committed
101
  // -1.
102 103 104
  virtual vtkIdType GetNearestPoint(const vtkVector2f& point,
                                    const vtkVector2f& tolerance,
                                    vtkVector2f* location);
Keith Fieldhouse's avatar
Keith Fieldhouse committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118

  // Description:
  // Select all points in the specified rectangle.
  virtual bool SelectPoints(const vtkVector2f& min, const vtkVector2f& max);

protected:
  vtkPlotStacked();
  ~vtkPlotStacked();

  // Description:
  // Update the table cache.
  bool UpdateTableCache(vtkTable *table);

  // Descript:
119
  // For stacked plots the Extent data must be greater than (or equal to) the
Keith Fieldhouse's avatar
Keith Fieldhouse committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  // base data. Insure that this is true
  void FixExtent();

  // Description:
  // 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.
  void CalculateLogSeries();

  // Description:
  // 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.
  vtkIdTypeArray* BaseBadPoints;

  // Description:
  // 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.
  vtkIdTypeArray* ExtentBadPoints;

  // Description:
  // The point cache is marked dirty until it has been initialized.
  vtkTimeStamp BuildTime;

  bool LogX, LogY;

Keith Fieldhouse's avatar
Keith Fieldhouse committed
144 145 146 147
  // Description:
  // The color series to use for each series.
  vtkSmartPointer<vtkColorSeries> ColorSeries;

Keith Fieldhouse's avatar
Keith Fieldhouse committed
148
private:
149
  vtkPlotStacked(const vtkPlotStacked &) VTK_DELETE_FUNCTION;
150
  void operator=(const vtkPlotStacked &) VTK_DELETE_FUNCTION;
Keith Fieldhouse's avatar
Keith Fieldhouse committed
151

Keith Fieldhouse's avatar
Keith Fieldhouse committed
152 153
  vtkPlotStackedPrivate *Private;

Keith Fieldhouse's avatar
Keith Fieldhouse committed
154 155
};

156
#endif //vtkPlotStacked_h