Exemplo n.º 1
0
        private void dataGridViewTraceHeader_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (!changeActive)
            {
                return;
            }
            if (f == null)
            {
                return;            // file not open
            }
            if (e.ColumnIndex != 4 && e.ColumnIndex != 5)
            {
                return;                                         // only edit value set or increment
            }
            SEGYTraceHeader fh    = f.currentTrace.TraceHeader; // active object
            int             rowid = e.RowIndex;

            propertyInfos = typeof(SEGYTraceHeader).GetProperties();
            PropertyInfo p = propertyInfos[rowid];
            object       val;

            try
            {
                val = Convert.ChangeType(dataGridViewTraceHeader.Rows[rowid].Cells[e.ColumnIndex].Value, p.PropertyType);
            }
            catch (SystemException ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                dataGridViewTraceHeader.Rows[rowid].Cells[3].Value = p.GetValue(fh, null);
                return;
            }
            p.SetValue(fh, val, null);
            refreshTraceHeader();
        }
Exemplo n.º 2
0
        /// <summary>
        /// initilize trace structure
        /// </summary>
        /// <param name="isBigEndian">is the file big endian or little endian</param>
        /// <param name="format">format of data word length according to SEGY standard</param>
        ///  <param name="number_of_points_in_trace">format of data word length according to SEGY standard</param>
        ///
        public void Intialize(bool isBigEndian, int format, int number_of_points_in_trace = 0)
        {
            iSEGYTraceData = new SEGYTraceData();
            iSEGYTraceData.Initialize(format, isBigEndian, number_of_points_in_trace);

            iSEGYTraceHeader = new SEGYTraceHeader();
            iSEGYTraceHeader.Initialize(isBigEndian);
            iformat = format;
        }
Exemplo n.º 3
0
        /// <summary>
        /// read the file header from disk
        /// </summary>
        /// <param name="br">binary reader stream</param>
        /// <returns>true if successful</returns>
        public bool ReadFileHeader(BinaryReader br)
        {
            this.br = br;

            // read text header
            byte[] t0 = br.ReadBytes(3200);
            //remove pre-initialized vaue
            this.ExtendedTextHeader.Clear();
            this.ExtendedTextHeader.Add(t0); // note 1st TextHeader block is alwats the firsr 3200 bytes in the file

            // read file header
            byte[] fh = br.ReadBytes(400);
            this.BinaryFileHeader = fh;

            // check byte order
            BigEndian = isBigEndian();

            positionOfStartOfDataTraces = br.BaseStream.Position; // record the positionTraceReacorded of the start of the data traces


            // check SEGY revision - SEGY Version 1.0 encoded as 0100 base 16.
            if (this.segyFormatRevisionNumber >= 256)
            {
                if ((int)this.numberOfExtendedTextualFileHeaderRecordsFollowing < 100)
                {
                    // may have extended headers
                    for (int i = 0; i < (int)this.numberOfExtendedTextualFileHeaderRecordsFollowing; i++)
                    {
                        t0 = br.ReadBytes(3200);
                        this.ExtendedTextHeader.Add(t0);
                    }
                }
                else
                {
                    this.detectedSEGYVer0 = true; // probably
                }
            }
            long saveposition = br.BaseStream.Position;
            // sometimes the file is SEGY rev 0 and there is crap in the header fields
            // let's check to see is the next trace makes sense

            SEGYTraceHeader th = new SEGYTraceHeader();

            th.Initialize(this.isBigEndian());
            th.TraceHeaderBuffer = br.ReadBytes(240);
            if (th.yearDataRecorded < 1950 || th.yearDataRecorded > 2050)
            {
                this.detectedSEGYVer0 = true;
            }
            if (th.dayOfYear < 1 || th.dayOfYear > 366)
            {
                this.detectedSEGYVer0 = true;
            }
            if (th.hourOfDay < 0 || th.hourOfDay > 24)
            {
                this.detectedSEGYVer0 = true;
            }
            if (th.minuteOfHour < 0 || th.minuteOfHour > 60)
            {
                this.detectedSEGYVer0 = true;
            }
            if (th.secondOfMinute < 0 || th.secondOfMinute > 60)
            {
                this.detectedSEGYVer0 = true;
            }
            if (this.detectedSEGYVer0)
            {
                br.BaseStream.Position = positionOfStartOfDataTraces;
                this.ExtendedTextHeader.RemoveRange(1, ExtendedTextHeader.Count - 1);
            }
            else
            {
                br.BaseStream.Position = br.BaseStream.Position - 240; // backup last header read
            }

            positionOfStartOfDataTraces = br.BaseStream.Position; // record the positionTraceReacorded of the start of the data traces

            isSEGYFileHeaderAscii = isFileHeaderASCII();

            return(true);
        }