vtkAxisExtended.h 4.14 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkCellLocator.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 vtkAxisExtended - octree-based spatial search object to quickly locate cells
// .SECTION Description
// This implements the optimization based tick position calculating algorithm in the paper "An Extension of Wilkinson's Algorithm
// for Positioning Tick Labels on Axes" by Junstin Talbot, Sharon Lin and Pat Hanrahan

// .SECTION Caveats

// .SECTION See Also
23
// vtkAxis
24

25 26
#ifndef vtkAxisExtended_h
#define vtkAxisExtended_h
27 28
#endif

29
#include "vtkChartsCoreModule.h" // For export macro
30
#include "vtkObject.h"
31
#include "vtkVector.h" // Needed for vtkVector
32

33
class VTKCHARTSCORE_EXPORT vtkAxisExtended : public vtkObject
34 35 36 37
{
public:
   vtkTypeMacro(vtkAxisExtended, vtkObject);
   static vtkAxisExtended *New();
38
   virtual void PrintSelf(ostream& os, vtkIndent indent);
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

   // Description:
   // This method return a value to make step sizes corresponding to low q
   // and j values more preferable
   static double Simplicity(int qIndex, int qLength, int j, double lmin,
                            double lmax, double lstep);

   // Description:
   // This method returns the maximum possible value of simplicity value given
   // q and j
   static double SimplicityMax(int qIndex, int qLength, int j);

   // Description:
   // This method makes the data range approximately same as the labeling
   // range more preferable
   static double Coverage(double dmin, double dmax, double lmin, double lmax);

   // Description:
   //This gives the maximum possible value of coverage given the step size
   static double CoverageMax(double dmin, double dmax, double span);

   // Description:
   // This method return a value to make the density of the labels close to
   // the user given value
   static double Density(int k, double m, double dmin, double dmax,
                         double lmin, double lmax);

   // Description:
   // Derives the maximum values for density given k (number of ticks) and
   // m (user given)
   static double DensityMax(int k, double m);

   // Description:
Kyle Lutz's avatar
Kyle Lutz committed
72
   // This methods return the legibility score of different formats
73 74 75
   static double FormatLegibilityScore(double n, int format);

   // Description:
Kyle Lutz's avatar
Kyle Lutz committed
76
   // This method returns the string length of different format notations.
77 78 79 80
   static int FormatStringLength(int format, double n, int precision);

   // Description:
   // This method implements the algorithm given in the paper
Kyle Lutz's avatar
Kyle Lutz committed
81
   // The method return the minimum tick position, maximum tick position and
82 83 84 85 86 87 88 89 90 91 92 93
   // the tick spacing
   vtkVector3d GenerateExtendedTickLabels(double dmin, double dmax, double m,
                                          double scaling);

   // Description:
   // Set/Get methods for variables
   vtkGetMacro(FontSize, int);
   vtkSetMacro(FontSize, int);

   vtkGetMacro(DesiredFontSize, int);
   vtkSetMacro(DesiredFontSize, int);

94 95
   vtkGetMacro(Precision, int);
   vtkSetMacro(Precision, int);
96 97 98 99 100 101
   vtkGetMacro(LabelFormat, int);
   vtkSetMacro(LabelFormat, int);

   vtkGetMacro(Orientation, int);
   vtkSetMacro(Orientation, int);

102
   vtkGetMacro(IsAxisVertical, bool);
103 104 105 106 107 108
   vtkSetMacro(IsAxisVertical, bool);

protected:
  vtkAxisExtended();
  ~vtkAxisExtended();

109 110 111 112 113
  // Description:
  // This method implements an exhaustive search of the legibilty parameters.
  double Legibility(double lmin, double lmax, double lstep, double scaling,
                    vtkVector<int, 3>& parameters);

114 115 116
  int Orientation;
  int FontSize;
  int DesiredFontSize;
117
  int Precision;
118 119 120 121 122
  int LabelFormat;
  bool LabelLegibilityChanged;
  bool IsAxisVertical;

private:
123
  vtkAxisExtended(const vtkAxisExtended&) VTK_DELETE_FUNCTION;
124
  void operator=(const vtkAxisExtended&) VTK_DELETE_FUNCTION;
125
};