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
16namespace Pulsar {
17
18 class Archive;
19
21 class PlotScale : public PlotEdge {
22
23 public:
24
26 PlotScale ();
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, bool cyclic = false) const;
70
72 void get_axis_indeces (unsigned n, float& imin, float& imax, bool cyclic = false) const;
73
75 void get_range_external (float& min, float& max) const;
76
78 void set_range_norm (const std::pair<float,float>& f);
79
81 std::pair<float,float> get_range_norm () const { return range_norm; }
82
84 void set_range_norm (float min, float max)
85 { set_range_norm (std::pair<float,float>(min, max)); }
86
88 void set_buf_norm (float f) { buf_norm = f; }
89
91 float get_buf_norm () const { return buf_norm; }
92
94 void set_world (const std::pair<float,float>& f);
95
97 std::pair<float,float> get_world () const { return world; }
98
100 void set_world_external (const std::pair<float,float>& f);
101
103 std::pair<float,float> get_world_external () const;
104
106 void set_index_range ( const std::pair<unsigned,unsigned>& index );
108 std::pair<unsigned,unsigned> get_index_range () const;
109
110 unsigned get_num_indeces () const { return num_indeces; }
111
112 std::pair<float,float> viewport_to_world (const std::pair<float,float>&);
113 double viewport_to_world (const double);
114
116 virtual void freeze (bool f = true) { frozen = f; }
117
118 protected:
119
120 std::pair<float,float> world;
121
122 std::pair<float,float> range_norm;
123
124 std::pair<float,float> world_external;
125
126 std::pair<unsigned, unsigned> index_range;
127
128 unsigned num_indeces = 0;
129 float buf_norm = 0.0;
130 float minval = 0.0;
131 float maxval = 1.0;
132 bool minmaxvalset = false;
133 bool frozen = false;
134 };
135
136
137}
138
139#endif
The primary interface to pulsar observational data.
Definition Archive.h:46
void set_index_range(const std::pair< unsigned, unsigned > &index)
Set the index range to be plotted.
Definition PlotScale.C:114
bool get_minmaxset() const
Return true when minimum and maximum value have been set.
Definition PlotScale.h:54
void set_range_norm(const std::pair< float, float > &f)
Set the world-normalized range on the axis.
Definition PlotScale.C:93
std::pair< float, float > get_world() const
Get the world coordinate range in the viewport.
Definition PlotScale.h:97
std::pair< unsigned, unsigned > get_index_range() const
Get the index range to be plotted.
Definition PlotScale.C:120
void set_buf_norm(float f)
Set the world-normalized buffer space on either side of the axis.
Definition PlotScale.h:88
virtual void init(const Archive *)
Initialize internal attributes according to Archive data.
Definition PlotScale.C:28
void set_world(const std::pair< float, float > &f)
Set the world coordinate range in the viewport.
Definition PlotScale.C:98
void get_axis_indeces(unsigned n, float &imin, float &imax, bool cyclic=false) const
Return axis indeces scaled according to zoom.
Definition PlotScale.C:236
void set_world_external(const std::pair< float, float > &f)
Set the world coordinate range printed on the axis.
Definition PlotScale.C:103
void update_minmax(float min, float max)
Update the minimum and maximum value in the data.
Definition PlotScale.C:62
virtual std::string get_label() const
Get a description of the units.
Definition PlotScale.h:48
std::pair< float, float > get_world_external() const
Get the world coordinate range printed on the axis.
Definition PlotScale.C:108
void set_range_norm(float min, float max)
Convenience interface.
Definition PlotScale.h:84
void include(PlotScale *other)
Expand as necessary to include another PlotScale.
Definition PlotScale.C:33
virtual void freeze(bool f=true)
Freeze the frame.
Definition PlotScale.h:116
void get_range_external(float &min, float &max) const
Return min and max scaled according to zoom.
Definition PlotScale.C:181
std::pair< float, float > get_minmax() const
Get the world coordinate range printed on the axis.
Definition PlotScale.C:88
PlotScale()
Default constructor.
Definition PlotScale.C:20
void copy(PlotScale *other)
Copy another PlotScale.
Definition PlotScale.C:43
std::pair< float, float > get_range_norm() const
Get the world-normalized range on the axis.
Definition PlotScale.h:81
void set_minmax(float min, float max)
Set the minimum and maximum value in the data.
Definition PlotScale.C:52
void get_range(float &min, float &max) const
Return min and max scaled according to zoom.
Definition PlotScale.C:142
void get_indeces(unsigned n, unsigned &imin, unsigned &imax, bool cyclic=false) const
Return array indeces that span the axis indeces.
Definition PlotScale.C:192
float get_buf_norm() const
Get the world-normalized buffer space on either side of the axis.
Definition PlotScale.h:91
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0