-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotgraph_ding.ccl
127 lines (99 loc) · 3.38 KB
/
plotgraph_ding.ccl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
This file is to draw a window to plot chart
*/
// Written by [Mengjia Ding] [22-12-2017]
// Pi: OSLO constant
// Dr: OSLO constant to convert degree to radians
#include "../../public/ccl/inc/gendefs.h"
cmd plot_graph_own(int graph_win_size_min, int graph_win_size_max) // suggest input 50,700
{
static int ssb_row_sav;
//static char str1[80], str2[80], str3[80]; // initialise string vectors for message in notice board
int x_pos_win[650], y_pos_win_index[650];
real y_pos_win[650];
real y_pos_win_rel, y_pos_win_abs, y_pos_win_pct;
real z_origin;
SAVE_DISPLAY_PREFS; // as defined in gendefs.h
set_preference(outp, off); // switch off the text output
ssb_row_sav = sbrow;
ssbuf_reset(ssb_row_sav,1); // clear the spreadsheet buffer
graphwin_reset;
//graphwin_open(2, 700, 700, 0, 0); // Win_index, Win_width, Win_height, Win_x & Win_y
// are the position of upper left corner of the win
//*************************************************
// Open the windonw
// Plot the abscissa and ordinate plus those titles
//*************************************************
window -graph_win_size_min graph_win_size_max -graph_win_size_min graph_win_size_max; // win_x_min, win_x_man, win_y_min, win_y_max
// Set abscissa and x label
moveto(0,0); // start from the origin
pen(1); // line colour
lineto(graph_win_size_max-graph_win_size_min,0); // set length of abscissa
for(i = 1; i<ceil((graph_win_size_max-graph_win_size_min)/50); i++) // for-loop to draw the abscissa symbols
{
moveto(0+i*50,0); // every 50 pixels a gap
linerel(0, -2); // symbol height
}
moverel(-200,-30); // set x label start position
//lspacing -0.5 0;
lsize 0.9; // change the size of characters - 0 is standard
label("%s","Detector Distance (mm)"); // set x label
// Set ordinate and y label
moveto(0,0); // back to origin
lineto(0,graph_win_size_max-graph_win_size_min); // set length of the ordinate
for(i = 1; i<ceil((graph_win_size_max-graph_win_size_min)/50); i++)
{
moveto(0, 0+i*50);
linerel(-2, 0);
}
moverel(-20,-400);
langle -90; // Rotate the text in Y
//lspacing -0.5 0; // change the seperation of characters and lines
lsize 0.9;
label("%s","MSE Spot Size error (mm");
moverel(-10,10);
langle -90;
lsize 0.5;
label("%s","2");
moverel(10,5);
langle -90;
lsize 0.9;
label("%s",")");
// Start to inset the data that want to be drew in the window
// 23-12-17 update
// draw the MSE of Spot Size vs Diffraction Limit as a function of detector distance
moveto(0,0);
pen(1);
z_origin = th[ims-1];
th(ims-1, z_origin-0.325);
for(i = 0; i < 650; i++)
{
th(ims-1, th[ims-1]+0.001);
//printf("Current Detector Distance: %.4f \n",th[ims-1]);
x_pos_win[i] = i+1;
set_object_point(0, 0, 0);
spd mon none 44 1;
y_pos_win[i] = fabs(ssb(7,3)-ssb(7,4));
sbr;
}
sort(y_pos_win_index, y_pos_win); // sort the postion of y in ascending order, first index is min and last index is max
for(i = 0; i < 650; i++)
{
y_pos_win_rel = y_pos_win[i] - y_pos_win[y_pos_win_index[0]];
y_pos_win_abs = y_pos_win[y_pos_win_index[649]] - y_pos_win[y_pos_win_index[0]];
y_pos_win_pct = y_pos_win_rel/y_pos_win_abs;
if(i == 0 )
{
moveto(x_pos_win[i],y_pos_win_pct*650);
pen(2);
}
else
{
lineto(x_pos_win[i],y_pos_win_pct*650);
}
}
set_preference(outp, on); // switch on the text output
gshow;
RESTORE_DISPLAY_PREFS;
th(ims-1, z_origin);
}