source: trunk/src/Plotter2.h@ 2937

Last change on this file since 2937 was 2909, checked in by WataruKawasaki, 11 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes:

Module(s): sd

Description: (1) a bug fix in sd.scantable.parse_spw_selection(). modified to get rest frequency value correctly based on molecule ID stored for each spw (the first spectrum having the specified spw in scantable). (2) renamed 'annotation' to 'text' in class or variable names for sd.plotter2.


File size: 7.7 KB
Line 
1#include <cstdlib>
2#include <iostream>
3#include <math.h>
4#include <stdio.h>
5#include <string>
6#include <unistd.h>
7#include <vector>
8
9#include <cpgplot.h>
10
11namespace asap {
12
13class Plotter2TextInfo {
14public:
15 Plotter2TextInfo();
16 ~Plotter2TextInfo();
17
18 std::string text;
19 float posx;
20 float posy;
21 float angle;
22 float fjust;
23 float size;
24 int color;
25 int bgcolor;
26};
27
28class Plotter2ArrowInfo {
29public:
30 Plotter2ArrowInfo();
31 ~Plotter2ArrowInfo();
32
33 float xhead;
34 float xtail;
35 float yhead;
36 float ytail;
37
38 int color;
39 int width;
40 int lineStyle;
41 float headSize;
42 int headFillStyle;
43 float headAngle;
44 float headVent;
45};
46
47class Plotter2RectInfo {
48public:
49 Plotter2RectInfo();
50 ~Plotter2RectInfo();
51
52 float xmin;
53 float xmax;
54 float ymin;
55 float ymax;
56
57 int color;
58 int fill;
59 int width;
60 float hsep;
61};
62
63class Plotter2DataInfo {
64public:
65 Plotter2DataInfo();
66 ~Plotter2DataInfo();
67
68 std::vector<float> xData;
69 std::vector<float> yData;
70
71 bool drawLine;
72 int lineColor;
73 int lineWidth;
74 int lineStyle;
75
76 bool drawMarker;
77 int markerType;
78 float markerSize;
79 int markerColor;
80
81 bool hasData;
82};
83
84class Plotter2ViewportInfo {
85public:
86 Plotter2ViewportInfo();
87 ~Plotter2ViewportInfo();
88
89 // show the whole viewport
90 bool showViewport;
91
92 // viewport position in window-coordinate
93 float vpPosXMin;
94 float vpPosXMax;
95 float vpPosYMin;
96 float vpPosYMax;
97
98 // plotting range in world-coordinate
99 float vpRangeXMin;
100 float vpRangeXMax;
101 float vpRangeYMin;
102 float vpRangeYMax;
103
104 // set plotting range automatic
105 bool isAutoRangeX;
106 bool isAutoRangeY;
107 float autoRangeMarginX;
108 float autoRangeMarginY;
109 void adjustRange();
110 std::vector<float> getRangeX();
111 std::vector<float> getRangeY();
112
113 // tick intervals
114 bool isAutoTickIntervalX;
115 bool isAutoTickIntervalY;
116 float majorTickIntervalX;
117 float majorTickIntervalY;
118 int nMajorTickWithinTickNumsX;
119 int nMajorTickWithinTickNumsY;
120 int nMinorTickWithinMajorTicksX;
121 int nMinorTickWithinMajorTicksY;
122 void adjustTickInterval();
123
124 // location of value strings along axes
125 std::string numLocationX;
126 std::string numLocationY;
127
128 // default font size
129 float fontSizeDef;
130
131 // data to be plotted
132 std::vector<Plotter2DataInfo> vData;
133 void setData(const std::vector<float>& inXData, const std::vector<float>& inYData, const int id);
134
135 // rectangles
136 std::vector<Plotter2RectInfo> vRect;
137
138 // arrows
139 std::vector<Plotter2ArrowInfo> vArro;
140
141 //annotations
142 std::vector<Plotter2TextInfo> vText;
143
144 // x-label
145 std::string labelXString;
146 float labelXPosX;
147 float labelXPosY;
148 float labelXAngle;
149 float labelXFJust;
150 float labelXSize;
151 int labelXColor;
152 int labelXBColor;
153
154 // y-label
155 std::string labelYString;
156 float labelYPosX;
157 float labelYPosY;
158 float labelYAngle;
159 float labelYFJust;
160 float labelYSize;
161 int labelYColor;
162 int labelYBColor;
163
164 // title
165 std::string titleString;
166 float titlePosX;
167 float titlePosY;
168 float titleAngle;
169 float titleFJust;
170 float titleSize;
171 int titleColor;
172 int titleBColor;
173
174 // background colour
175 int vpBColor;
176
177 void getWorldCoordByWindowCoord(const float winX, const float winY, float* worldX, float* worldY);
178
179private:
180 float minXData;
181 float maxXData;
182 float minYData;
183 float maxYData;
184 bool hasDataRange;
185 void updateXDataRange(const float data);
186 void updateYDataRange(const float data);
187 void updateAllDataRanges();
188 void adjustRangeX(float* xmin, float* xmax);
189 void adjustRangeY(float* ymin, float* ymax);
190 void adjustTickIntervalX(const float xmin, const float xmax);
191 void adjustTickIntervalY(const float ymin, const float ymax);
192};
193
194class Plotter2 {
195public:
196 Plotter2();
197 ~Plotter2();
198
199 std::string getFileName();
200 void setFileName(const std::string& inFilename);
201 std::string getDevice();
202 void setDevice(const std::string& inDevice);
203
204 float getViewSurfaceWidth();
205 float getViewSurfaceAspect();
206 void setViewSurface(const float width, const float aspect);
207 int addViewport(const float xmin, const float xmax, const float ymin, const float ymax);
208 void setViewport(const float xmin, const float xmax, const float ymin, const float ymax, const int id);
209 void showViewport(const int inVpid);
210 void hideViewport(const int inVpid);
211 bool getHasDefaultViewport();
212 int getCurrentViewportId();
213 void getViewInfo();
214 void setRange(const float xmin, const float xmax, const float ymin, const float ymax, const int inVpid);
215 void setRangeX(const float xmin, const float xmax, const int inVpid);
216 void setRangeY(const float ymin, const float ymax, const int inVpid);
217 std::vector<float> getRangeX(const int inVpid);
218 std::vector<float> getRangeY(const int inVpid);
219 void setAutoRange(const int inVpid);
220 void setAutoRangeX(const int inVpid);
221 void setAutoRangeY(const int inVpid);
222 void setFontSizeDef(const float size, const int inVpid);
223 void setTicksX(const float interval, const int num, const int inVpid);
224 void setTicksY(const float interval, const int num, const int inVpid);
225 void setAutoTicks(const int inVpid);
226 void setAutoTicksX(const int inVpid);
227 void setAutoTicksY(const int inVpid);
228 void setNumIntervalX(const float interval, const int inVpid);
229 void setNumIntervalY(const float interval, const int inVpid);
230 void setNumLocationX(const std::string& side, const int inVpid);
231 void setNumLocationY(const std::string& side, const int inVpid);
232 void setData(const std::vector<float>& xdata, const std::vector<float>& ydata, const int inVpid, const int inDataid);
233 void setLine(const int color, const int width, const int style, const int inVpid, const int inDataid);
234 void showLine(const int inVpid, const int inDataid);
235 void hideLine(const int inVpid, const int inDataid);
236 void setPoint(const int type, const float size, const int color, const int inVpid, const int inDataid);
237 void showPoint(const int inVpid, const int inDataid);
238 void hidePoint(const int inVpid, const int inDataid);
239 void setMaskX(const float xmin, const float xmax, const int color, const int fill, const int width, const float hsep, const int inVpid);
240 void setArrow(const float xtail, const float xhead, const float ytail, const float yhead, const int color, const int width, const int lineStyle, const float headSize, const int headFillStyle, const float headAngle, const float headVent, const int inVpid, const int inArrowid);
241 void setText(const std::string& text, const float inPosx, const float inPosy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inTextid);
242 void setLabelX(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
243 void setLabelY(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
244 void setTitle(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);
245 void setViewportBackgroundColor(const int bgcolor, const int inVpid);
246 void plot();
247private:
248 std::string filename;
249 std::string device;
250 bool hasDevice;
251 std::vector<Plotter2ViewportInfo> vInfo;
252 bool hasDefaultViewport;
253 int currentViewportId;
254 float width;
255 float aspect;
256 void open();
257 void close();
258 void resetAttributes(const Plotter2ViewportInfo& vi);
259};
260
261} // namespace asap
Note: See TracBrowser for help on using the repository browser.