source: trunk/src/Plotter2.h@ 2849

Last change on this file since 2849 was 2839, checked in by WataruKawasaki, 11 years ago

New Development: No

JIRA Issue: Yes CAS-3620

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: Yes

Module(s): sd

Description: add including cstdlib in Ploter2.h as suggested by Sanjay


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