PlotScale.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2006 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/Plotting/Pulsar/PlotScale.h
10 
11 #ifndef __Pulsar_PlotScale_h
12 #define __Pulsar_PlotScale_h
13 
14 #include "Pulsar/PlotEdge.h"
15 
16 namespace Pulsar {
17 
18  class Archive;
19 
21  class PlotScale : public PlotEdge {
22 
23  public:
24 
27 
28  // Text interface to the PlotScale class
29  class Interface : public TextInterface::To<PlotScale>
30  {
31  public:
32  Interface (PlotScale* = 0);
33  };
34 
35  virtual TextInterface::Parser* get_interface ()
36  { return new Interface(this); }
37 
39  virtual void init (const Archive*);
40 
42  void copy (PlotScale* other);
43 
45  void include (PlotScale* other);
46 
48  virtual std::string get_label () const { return ""; }
49 
51  void set_minmax (float min, float max);
52 
54  bool get_minmaxset () const { return minmaxvalset; }
55 
57  void get_minmax (float& min, float& max) const;
58 
60  void update_minmax (float min, float max);
61 
63  std::pair<float,float> get_minmax () const;
64 
66  void get_range (float& min, float& max) const;
67 
69  void get_indeces (unsigned n, unsigned& imin, unsigned& imax,
70  bool cyclic = false) const;
71 
73  void get_axis_indeces (unsigned n, float& imin, float& imax,
74  bool cyclic = false) const;
75 
77  void get_range_external (float& min, float& max) const;
78 
80  void set_range_norm (const std::pair<float,float>& f);
81 
83  std::pair<float,float> get_range_norm () const { return range_norm; }
84 
86  void set_range_norm (float min, float max)
87  { set_range_norm (std::pair<float,float>(min, max)); }
88 
90  void set_buf_norm (float f) { buf_norm = f; }
91 
93  float get_buf_norm () const { return buf_norm; }
94 
96  void set_world (const std::pair<float,float>& f);
97 
99  std::pair<float,float> get_world () const { return world; }
100 
102  void set_world_external (const std::pair<float,float>& f);
103 
105  std::pair<float,float> get_world_external () const;
106 
108  void set_index_range ( const std::pair<unsigned,unsigned>& index );
110  std::pair<unsigned,unsigned> get_index_range () const;
111 
112  unsigned get_num_indeces () const { return num_indeces; }
113 
114  std::pair<float,float> viewport_to_world (const std::pair<float,float>&);
115  double viewport_to_world (const double);
116 
118  virtual void freeze (bool f = true) { frozen = f; }
119 
120  protected:
121 
122  std::pair<float,float> world;
123 
124  std::pair<float,float> range_norm;
125 
126  std::pair<float,float> world_external;
127 
128  std::pair<unsigned, unsigned> index_range;
129  unsigned num_indeces;
130 
131  float buf_norm;
132  float minval;
133  float maxval;
134  bool minmaxvalset;
135  bool frozen;
136  };
137 
138 
139 }
140 
141 #endif
void copy(PlotScale *other)
Copy another PlotScale.
Definition: PlotScale.C:48
void update_minmax(float min, float max)
Update the minimum and maximum value in the data.
Definition: PlotScale.C:67
bool get_minmaxset() const
Return true when minimum and maximum value have been set.
Definition: PlotScale.h:59
std::pair< float, float > get_range_norm() const
Get the world-normalized range on the axis.
Definition: PlotScale.h:88
std::pair< float, float > get_minmax() const
Get the world coordinate range printed on the axis.
Definition: PlotScale.C:93
virtual void freeze(bool f=true)
Freeze the frame.
Definition: PlotScale.h:123
std::pair< float, float > get_world_external() const
Get the world coordinate range printed on the axis.
Definition: PlotScale.C:113
void get_axis_indeces(unsigned n, float &imin, float &imax, bool cyclic=false) const
Return axis indeces scaled according to zoom.
Definition: PlotScale.C:241
float get_buf_norm() const
Get the world-normalized buffer space on either side of the axis.
Definition: PlotScale.h:98
void set_buf_norm(float f)
Set the world-normalized buffer space on either side of the axis.
Definition: PlotScale.h:95
The primary interface to pulsar observational data.
Definition: Archive.h:45
virtual std::string get_label() const
Get a description of the units.
Definition: PlotScale.h:53
The scale on an axis.
Definition: PlotScale.h:26
virtual void init(const Archive *)
Initialize internal attributes according to Archive data.
Definition: PlotScale.C:33
PlotScale()
Default constructor.
Definition: PlotScale.C:20
std::pair< unsigned, unsigned > get_index_range() const
Get the index range to be plotted.
Definition: PlotScale.C:125
std::pair< float, float > get_world() const
Get the world coordinate range in the viewport.
Definition: PlotScale.h:104
void get_range(float &min, float &max) const
Return min and max scaled according to zoom.
Definition: PlotScale.C:147
void get_range_external(float &min, float &max) const
Return min and max scaled according to zoom.
Definition: PlotScale.C:186
void get_indeces(unsigned n, unsigned &imin, unsigned &imax, bool cyclic=false) const
Return array indeces that span the axis indeces.
Definition: PlotScale.C:197
void include(PlotScale *other)
Expand as necessary to include another PlotScale.
Definition: PlotScale.C:38
void set_index_range(const std::pair< unsigned, unsigned > &index)
Set the index range to be plotted.
Definition: PlotScale.C:119
void set_range_norm(const std::pair< float, float > &f)
Set the world-normalized range on the axis.
Definition: PlotScale.C:98
Defines the PSRCHIVE library.
Definition: CalSource.h:17
void set_world(const std::pair< float, float > &f)
Set the world coordinate range in the viewport.
Definition: PlotScale.C:103
void set_world_external(const std::pair< float, float > &f)
Set the world coordinate range printed on the axis.
Definition: PlotScale.C:108
void set_minmax(float min, float max)
Set the minimum and maximum value in the data.
Definition: PlotScale.C:57

Generated using doxygen 1.8.17