-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeom_ex.cpp
257 lines (186 loc) · 9.49 KB
/
geom_ex.cpp
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#include "geom_ex.h"
#include "ui_geom_ex.h"
#include <QtCharts>
#include <QScatterSeries>
#include <QVector>
#include <QByteArray>
#include <qcustomplot.h>
#include <mainwindow.h>
#include <QStatusBar>
using namespace QtCharts; //used when using charts, although simpler I will use qcustomplot to take advantage of zoomimg/panning capabilities
extern QString modelname;
extern quint32 tlength;
extern quint32 fillen;
QByteArray hd_temp2;
QByteArray tr_lbyte2[100];
QByteArray thead;
//WORKING HERE defining 3 columns array for the shot and receiver tables the QScatterSeries will be built after the tables have been created???!!
//creation of the tables will be based on the standard shot and receiver data in segy locations
// shotpoint 17-20 <- this is the key value for the table
// shotx 73-76
// shoty 77-80
// recx 81-84
// recy 85-88
geom_ex::geom_ex(QWidget *parent) :
QWidget(parent),
ui(new Ui::geom_ex)
{
ui->setupUi(this);
// After opening the map window we are going to read the entire SEGY and read from the segy standard all the shots locations.
QFile f(modelname);
f.open(QFile::ReadOnly);
QVector2D sp_coord((fillen-3200-400)/(240+4*tlength)-1,(fillen-3200-400)/(240+4*tlength)-1);
// QVector<double> spn((fillen-3200-400)/(240+4*tlength)-1); //Initializing vectors for shot number, shotx and shoty. fillen is the number of traces in the segy calculated in mainwindow.cpp
// QVector<double> spx((fillen-3200-400)/(240+4*tlength)-1), spy((fillen-3200-400)/(240+4*tlength)-1);
// QVector<double> recx((fillen-3200-400)/(240+4*tlength)-1), recy((fillen-3200-400)/(240+4*tlength)-1); //Initializing vectors for shot number, shotx and shoty. fillen is the number of traces in the segy calculated in mainwindow.cpp
QVector<double> spn(0); //Initializing vectors for shot number, shotx and shoty. fillen is the number of traces in the segy calculated in mainwindow.cpp
QVector<double> spx(0), spy(0);
QVector<double> recx(0), recy(0); //Initializing vectors for shot number, shotx and shoty. fillen is the number of traces in the segy calculated in mainwindow.cpp
quint32 kval=1;
do{
f.seek(3200+400+(240+4*tlength)*(kval-1));
thead=f.read(240);
// This section calculates the bytes to display the header attributes (4-bytes words)
int j =0;
for (int i = 0 ; i < 27 ;i = i + 4) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
hd_temp2.append(thead[i+2]);
hd_temp2.append(thead[i+3]);
// qDebug() << "Bytes after EBCDIC" << QString::fromLocal8Bit(hd_temp2) << hd_temp2.toHex().toInt(nullptr,16) << i ;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
// qDebug() << tr_lbyte2[4].toHex().toInt(nullptr,16) << k << (fillen-3200-400)/(240+4*tlength)-1 ;
// This section calculates the bytes to display the header attributes (2-bytes words)
for (int i = 28 ; i < 35 ;i = i + 2) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
// hd_temp2.append(thead[i+2]);
// hd_temp2.append(thead[i+3]);
// qDebug() << "Bytes after EBCDIC" << QString::fromLocal8Bit(hd_temp2) << hd_temp2.toHex().toInt(nullptr,16) << i ;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
// from 36 to 69 they are 4-byte words again
for (int i = 36 ; i < 67 ;i = i + 4) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
hd_temp2.append(thead[i+2]);
hd_temp2.append(thead[i+3]);
// qDebug() << "Bytes after EBCDIC" << QString::fromLocal8Bit(temp2) << temp2.toHex().toInt(&ok,16) << i ;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
// from 69 to 71 they are 2-byte words again (scalars)
for (int i = 68 ; i < 71 ;i = i + 2) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
// hd_temp2.append(thead[i+2]);
// hd_temp2.append(thead[i+3]);
// QDataStream <--
// qDebug() << "Bytes after EBCDIC" << static_cast<int16_t>(hd_temp2.toHex().toInt(nullptr,16)) << i ;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
// from 72 to 89 they are 4-byte words again
for (int i = 72 ; i < 87 ;i = i + 4) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
hd_temp2.append(thead[i+2]);
hd_temp2.append(thead[i+3]);
// qDebug() << "Bytes after EBCDIC source and group coordinates" << QString::fromLocal8Bit(hd_temp2) << hd_temp2.toHex().toInt(nullptr,16) << i << j;
// qDebug() << (fillen-3200-400)/(240+4*tlength)-1;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
if(spn.indexOf(tr_lbyte2[4].toHex().toInt(nullptr,16))==-1){
spn.append(tr_lbyte2[4].toHex().toInt(nullptr,16));
spx.append(tr_lbyte2[21].toHex().toInt(nullptr,16));
spy.append(tr_lbyte2[22].toHex().toInt(nullptr,16));
}
if(recx.indexOf(tr_lbyte2[23].toHex().toInt(nullptr,16))==-1 && recy.indexOf(tr_lbyte2[24].toHex().toInt(nullptr,16))==-1){
recx.append(tr_lbyte2[23].toHex().toInt(nullptr,16));
recy.append(tr_lbyte2[24].toHex().toInt(nullptr,16));
}
// from 89 to 144 they are 2-byte words again
for (int i = 88 ; i < 143 ;i = i + 2) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
// hd_temp2.append(thead[i+2]);
// hd_temp2.append(thead[i+3]);
// qDebug() << "Bytes after EBCDIC" << QString::fromLocal8Bit(temp2) << temp2.toHex().toInt(&ok,16) << i ;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
// from 148 to 179 they are 2-byte words again
for (int i = 148 ; i < 179 ;i = i + 2) {
hd_temp2.append(thead[i]);
hd_temp2.append(thead[i+1]);
// hd_temp2.append(thead[i+2]);
// hd_temp2.append(thead[i+3]);
// qDebug() << "Bytes after EBCDIC" << QString::fromLocal8Bit(hd_temp2) << hd_temp2.toHex().toInt(nullptr,16) << i ;
tr_lbyte2[j]=hd_temp2;
hd_temp2=0;
j=j+1;
}
// qDebug() << "k=" <<k ;
kval=kval+1;
// }while(f.atEnd());
}while(kval<=(fillen-3200-400)/(240+4*tlength)-1 );
// }while(k<=280);
// for(int i=0;i<spn.size();i++){
// qDebug() << i << spn.at(i) << spx.at(i) << spy.at(i) ;
// }
// Adding graph with all the shots and the receivers
QPen pen;
pen.setWidth(1);
pen.setColor(QColor(255,0,0,255));
ui->mapplot->yAxis->setLabel("Northing (m)"); //adding labels
ui->mapplot->xAxis->setLabel("Easting (m)");
ui->mapplot->addGraph();
ui->mapplot->graph(0)->setScatterStyle(QCPScatterStyle::ssDisc);
ui->mapplot->graph(0)->setLineStyle(QCPGraph::lsNone);
ui->mapplot->graph(0)->setPen(pen);
ui->mapplot->graph(0)->addData(spx,spy); //check QCPMapData
ui->mapplot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
ui->mapplot->axisRect(0)->setRangeDrag(Qt::Horizontal|Qt::Vertical);
ui->mapplot->axisRect(0)->setRangeZoom(Qt::Horizontal|Qt::Vertical);
ui->mapplot->rescaleAxes();
QPen recpen;
recpen.setWidth(1);
recpen.setColor(QColor(0,0,255,255));
ui->mapplot->addGraph();
ui->mapplot->graph(1)->setScatterStyle(QCPScatterStyle::ssDiamond);
ui->mapplot->graph(1)->setLineStyle(QCPGraph::lsNone);
ui->mapplot->graph(1)->setPen(recpen);
ui->mapplot->graph(1)->addData(recx,recy); //check QCPMapData
// ui->mapplot->axisRect(1)->setRangeDrag(Qt::Horizontal|Qt::Vertical);
// ui->mapplot->axisRect(1)->setRangeZoom(Qt::Horizontal|Qt::Vertical);
ui->mapplot->rescaleAxes();
connect(ui->mapplot,&QCustomPlot::mousePress, this, &geom_ex::slotMousePress);
connect(ui->mapplot,&QCustomPlot::mouseMove, this, &geom_ex::slotMouseMove);
}
//void geom_ex::mousePressEvent(QMouseEvent *ev){
// ui->mapplot->mousePress(ev);
// qDebug() << ui->mapplot->mapFromGlobal(QCursor::pos()) << ui->mapplot->xAxis->pixelToCoord(ev->pos().x()) ;
//}
void geom_ex::slotMousePress(QMouseEvent *ev){
}
void geom_ex::slotMouseMove(QMouseEvent *ev){
long xc = ui->mapplot->xAxis->pixelToCoord(ev->pos().x());
long yc = ui->mapplot->yAxis->pixelToCoord(ev->pos().y());
ui->xcoord->setText("X="+QString::number(xc,10));
ui->ycoord->setText("Y="+QString::number(yc,10));
// qDebug() << ui->mapplot->xAxis->pixelToCoord(ev->pos().x()) << ui->mapplot->yAxis->pixelToCoord(ev->pos().y());
}
geom_ex::~geom_ex()
{
delete ui;
}